plugins exts CHANGE custom cardinality support dropped

Standard YANG stataments expect standard cardinality.
diff --git a/src/plugins_exts.h b/src/plugins_exts.h
index 33199ca..8ac2254 100644
--- a/src/plugins_exts.h
+++ b/src/plugins_exts.h
@@ -272,19 +272,7 @@
 };
 
 /**
- * @brief Possible cardinalities of the YANG statements.
- *
- * Used in extensions plugins to define cardinalities of the extension instance substatements.
- */
-enum ly_stmt_cardinality {
-    LY_STMT_CARD_OPT,    /* 0..1 */
-    LY_STMT_CARD_MAND,   /* 1 */
-    LY_STMT_CARD_SOME,   /* 1..n */
-    LY_STMT_CARD_ANY     /* 0..n */
-};
-
-/**
- * @brief Helper structure for generic storage of the extension instances content.
+ * @brief Structure representing a generic parsed YANG substatement in an extension instance.
  */
 struct lysp_stmt {
     const char *stmt;                /**< identifier of the statement */
@@ -329,9 +317,8 @@
  */
 struct lysc_ext_substmt {
     enum ly_stmt stmt;                     /**< allowed substatement */
-    enum ly_stmt_cardinality cardinality;  /**< cardinality of the substatement */
     void *storage;                         /**< pointer to the storage of the compiled statement according to the specific
-                                                lysc_ext_substmt::stmt and lysc_ext_substmt::cardinality */
+                                                lysc_ext_substmt::stmt */
 };
 
 /**
@@ -363,6 +350,7 @@
     uint32_t plugins_extensions_apiver__ = LYPLG_EXT_API_VERSION; \
     const struct lyplg_ext_record plugins_extensions__[]
 
+typedef LY_ERR (*lyplg_ext_parse_clb)(struct lysp_ctx *pctx, struct lysp_ext_instance *p_ext);
 
 /**
  * @brief Callback to compile extension from the lysp_ext_instance to the lysc_ext_instance. The later structure is generally prepared
@@ -461,6 +449,7 @@
 struct lyplg_ext {
     const char *id;                         /**< plugin identification (mainly for distinguish incompatible versions
                                                  of the plugins for external tools) */
+    lyplg_ext_parse_clb parse;              /**< callback to parse the extension instance substatements */
     lyplg_ext_compile_clb compile;          /**< callback to compile extension instance from the parsed data */
     lyplg_ext_schema_printer_clb sprinter;  /**< callback to print the compiled content (info format) of the extension
                                                  instance */
@@ -496,14 +485,6 @@
 LIBYANG_API_DECL const char *ly_stmt2str(enum ly_stmt stmt);
 
 /**
- * @brief Stringify statement cardinality.
- *
- * @param[in] card The cardinality to stringify.
- * @return Constant string representation of the given @p card.
- */
-LIBYANG_API_DECL const char *ly_cardinality2str(enum ly_stmt_cardinality card);
-
-/**
  * @brief Convert nodetype to statement identifier
  *
  * @param[in] nodetype Nodetype to convert.
@@ -587,13 +568,10 @@
  * on the @p substmt and can be found in the documentation of each ::ly_stmt value. Also note that some of the substatements
  * (::lysc_node based or flags) can share the storage with other substatements. In case the pointer is NULL, still the return
  * code can be used to at least know if the substatement is allowed for the extension.
- * @param[out] cardinality_p Pointer to provide allowed cardinality of the substatements in the extension. Note that in some
- * cases, the type of the storage depends also on the cardinality of the substatement.
  * @return LY_SUCCESS if the @p substmt found.
  * @return LY_ENOT in case the @p ext is not able to store (does not allow) the specified @p substmt.
  */
-LIBYANG_API_DECL LY_ERR lysc_ext_substmt(const struct lysc_ext_instance *ext, enum ly_stmt substmt,
-        void **instance_p, enum ly_stmt_cardinality *cardinality_p);
+LIBYANG_API_DECL LY_ERR lysc_ext_substmt(const struct lysc_ext_instance *ext, enum ly_stmt substmt, void **instance_p);
 
 /** @} pluginsExtensions */
 
diff --git a/src/plugins_exts/metadata.c b/src/plugins_exts/metadata.c
index 8326f6b..f6e1580 100644
--- a/src/plugins_exts/metadata.c
+++ b/src/plugins_exts/metadata.c
@@ -81,32 +81,26 @@
 
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[ANNOTATION_SUBSTMT_IFF].stmt = LY_STMT_IF_FEATURE;
-    c_ext->substmts[ANNOTATION_SUBSTMT_IFF].cardinality = LY_STMT_CARD_ANY;
     c_ext->substmts[ANNOTATION_SUBSTMT_IFF].storage = &annotation->iffeatures;
 
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[ANNOTATION_SUBSTMT_UNITS].stmt = LY_STMT_UNITS;
-    c_ext->substmts[ANNOTATION_SUBSTMT_UNITS].cardinality = LY_STMT_CARD_OPT;
     c_ext->substmts[ANNOTATION_SUBSTMT_UNITS].storage = &annotation->units;
 
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[ANNOTATION_SUBSTMT_STATUS].stmt = LY_STMT_STATUS;
-    c_ext->substmts[ANNOTATION_SUBSTMT_STATUS].cardinality = LY_STMT_CARD_OPT;
     c_ext->substmts[ANNOTATION_SUBSTMT_STATUS].storage = &annotation->flags;
 
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[ANNOTATION_SUBSTMT_TYPE].stmt = LY_STMT_TYPE;
-    c_ext->substmts[ANNOTATION_SUBSTMT_TYPE].cardinality = LY_STMT_CARD_MAND;
     c_ext->substmts[ANNOTATION_SUBSTMT_TYPE].storage = &annotation->type;
 
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[ANNOTATION_SUBSTMT_DSC].stmt = LY_STMT_DESCRIPTION;
-    c_ext->substmts[ANNOTATION_SUBSTMT_DSC].cardinality = LY_STMT_CARD_OPT;
     c_ext->substmts[ANNOTATION_SUBSTMT_DSC].storage = &annotation->dsc;
 
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[ANNOTATION_SUBSTMT_REF].stmt = LY_STMT_REFERENCE;
-    c_ext->substmts[ANNOTATION_SUBSTMT_REF].cardinality = LY_STMT_CARD_OPT;
     c_ext->substmts[ANNOTATION_SUBSTMT_REF].storage = &annotation->ref;
 
     ret = lys_compile_extension_instance(cctx, p_ext, c_ext);
diff --git a/src/plugins_exts/structure.c b/src/plugins_exts/structure.c
index 3580ba3..12c548c 100644
--- a/src/plugins_exts/structure.c
+++ b/src/plugins_exts/structure.c
@@ -89,73 +89,59 @@
     LY_ARRAY_CREATE_GOTO(cctx->ctx, c_ext->substmts, 14, rc, emem);
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[0].stmt = LY_STMT_MUST;
-    c_ext->substmts[0].cardinality = LY_STMT_CARD_ANY;
     c_ext->substmts[0].storage = &struct_data->musts;
 
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[1].stmt = LY_STMT_STATUS;
-    c_ext->substmts[1].cardinality = LY_STMT_CARD_OPT;
     c_ext->substmts[1].storage = &struct_data->flags;
 
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[2].stmt = LY_STMT_DESCRIPTION;
-    c_ext->substmts[2].cardinality = LY_STMT_CARD_OPT;
     c_ext->substmts[2].storage = &struct_data->dsc;
 
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[3].stmt = LY_STMT_REFERENCE;
-    c_ext->substmts[3].cardinality = LY_STMT_CARD_OPT;
     c_ext->substmts[3].storage = &struct_data->ref;
 
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[4].stmt = LY_STMT_TYPEDEF;
-    c_ext->substmts[4].cardinality = LY_STMT_CARD_ANY;
     c_ext->substmts[4].storage = &struct_data->typedefs;
 
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[5].stmt = LY_STMT_GROUPING;
-    c_ext->substmts[5].cardinality = LY_STMT_CARD_ANY;
     c_ext->substmts[5].storage = &struct_data->groupings;
 
     /* data-def-stmt */
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[6].stmt = LY_STMT_CONTAINER;
-    c_ext->substmts[6].cardinality = LY_STMT_CARD_ANY;
     c_ext->substmts[6].storage = &struct_data->child;
 
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[7].stmt = LY_STMT_LEAF;
-    c_ext->substmts[7].cardinality = LY_STMT_CARD_ANY;
     c_ext->substmts[7].storage = &struct_data->child;
 
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[8].stmt = LY_STMT_LEAF_LIST;
-    c_ext->substmts[8].cardinality = LY_STMT_CARD_ANY;
     c_ext->substmts[8].storage = &struct_data->child;
 
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[9].stmt = LY_STMT_LIST;
-    c_ext->substmts[9].cardinality = LY_STMT_CARD_ANY;
     c_ext->substmts[9].storage = &struct_data->child;
 
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[10].stmt = LY_STMT_CHOICE;
-    c_ext->substmts[10].cardinality = LY_STMT_CARD_ANY;
     c_ext->substmts[10].storage = &struct_data->child;
 
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[11].stmt = LY_STMT_ANYDATA;
-    c_ext->substmts[11].cardinality = LY_STMT_CARD_ANY;
     c_ext->substmts[11].storage = &struct_data->child;
 
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[12].stmt = LY_STMT_ANYXML;
-    c_ext->substmts[12].cardinality = LY_STMT_CARD_ANY;
     c_ext->substmts[12].storage = &struct_data->child;
 
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[13].stmt = LY_STMT_USES;
-    c_ext->substmts[13].cardinality = LY_STMT_CARD_ANY;
     c_ext->substmts[13].storage = &struct_data->child;
 
     *lysc_ctx_get_options(cctx) |= LYS_COMPILE_NO_CONFIG | LYS_COMPILE_NO_DISABLED;
@@ -232,64 +218,52 @@
     LY_ARRAY_CREATE_GOTO(cctx->ctx, c_ext->substmts, 12, rc, emem);
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[0].stmt = LY_STMT_STATUS;
-    c_ext->substmts[0].cardinality = LY_STMT_CARD_OPT;
     c_ext->substmts[0].storage = &aug_data->flags;
 
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[1].stmt = LY_STMT_DESCRIPTION;
-    c_ext->substmts[1].cardinality = LY_STMT_CARD_OPT;
     c_ext->substmts[1].storage = &aug_data->dsc;
 
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[2].stmt = LY_STMT_REFERENCE;
-    c_ext->substmts[2].cardinality = LY_STMT_CARD_OPT;
     c_ext->substmts[2].storage = &aug_data->ref;
 
     /* data-def-stmt */
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[3].stmt = LY_STMT_CONTAINER;
-    c_ext->substmts[3].cardinality = LY_STMT_CARD_ANY;
     c_ext->substmts[3].storage = &target_data->child;
 
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[4].stmt = LY_STMT_LEAF;
-    c_ext->substmts[4].cardinality = LY_STMT_CARD_ANY;
     c_ext->substmts[4].storage = &target_data->child;
 
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[5].stmt = LY_STMT_LEAF_LIST;
-    c_ext->substmts[5].cardinality = LY_STMT_CARD_ANY;
     c_ext->substmts[5].storage = &target_data->child;
 
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[6].stmt = LY_STMT_LIST;
-    c_ext->substmts[6].cardinality = LY_STMT_CARD_ANY;
     c_ext->substmts[6].storage = &target_data->child;
 
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[7].stmt = LY_STMT_CHOICE;
-    c_ext->substmts[7].cardinality = LY_STMT_CARD_ANY;
     c_ext->substmts[7].storage = &target_data->child;
 
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[8].stmt = LY_STMT_ANYDATA;
-    c_ext->substmts[8].cardinality = LY_STMT_CARD_ANY;
     c_ext->substmts[8].storage = &target_data->child;
 
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[9].stmt = LY_STMT_ANYXML;
-    c_ext->substmts[9].cardinality = LY_STMT_CARD_ANY;
     c_ext->substmts[9].storage = &target_data->child;
 
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[10].stmt = LY_STMT_USES;
-    c_ext->substmts[10].cardinality = LY_STMT_CARD_ANY;
     c_ext->substmts[10].storage = &target_data->child;
 
     /* case */
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[11].stmt = LY_STMT_CASE;
-    c_ext->substmts[11].cardinality = LY_STMT_CARD_ANY;
     c_ext->substmts[11].storage = &target_data->child;
 
     *lysc_ctx_get_options(cctx) |= LYS_COMPILE_NO_CONFIG | LYS_COMPILE_NO_DISABLED;
diff --git a/src/plugins_exts/yangdata.c b/src/plugins_exts/yangdata.c
index 38e4c16..939709b 100644
--- a/src/plugins_exts/yangdata.c
+++ b/src/plugins_exts/yangdata.c
@@ -71,17 +71,14 @@
     LY_ARRAY_CREATE_GOTO(cctx->ctx, c_ext->substmts, 3, ret, emem);
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[0].stmt = LY_STMT_CONTAINER;
-    c_ext->substmts[0].cardinality = LY_STMT_CARD_OPT;
     c_ext->substmts[0].storage = &c_ext->data;
 
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[1].stmt = LY_STMT_CHOICE;
-    c_ext->substmts[1].cardinality = LY_STMT_CARD_OPT;
     c_ext->substmts[1].storage = &c_ext->data;
 
     LY_ARRAY_INCREMENT(c_ext->substmts);
     c_ext->substmts[2].stmt = LY_STMT_USES;
-    c_ext->substmts[2].cardinality = LY_STMT_CARD_OPT;
     c_ext->substmts[2].storage = &c_ext->data;
 
     *lysc_ctx_get_options(cctx) |= LYS_COMPILE_NO_CONFIG | LYS_COMPILE_NO_DISABLED;
diff --git a/src/printer_yang.c b/src/printer_yang.c
index 329c712..01ffa34 100644
--- a/src/printer_yang.c
+++ b/src/printer_yang.c
@@ -2505,18 +2505,9 @@
         case LY_STMT_PRESENCE:
         case LY_STMT_REFERENCE:
         case LY_STMT_UNITS:
-            if (ext->substmts[u].cardinality < LY_STMT_CARD_SOME) {
-                if (*(const char **)ext->substmts[u].storage) {
-                    ypr_open(pctx->out, flag);
-                    ypr_substmt(pctx, ext->substmts[u].stmt, 0, *(const char **)ext->substmts[u].storage, ext->exts);
-                }
-            } else {
-                const char **strings = *(const char ***)ext->substmts[u].storage;
-
-                LY_ARRAY_FOR(strings, v) {
-                    ypr_open(pctx->out, flag);
-                    ypr_substmt(pctx, ext->substmts[u].stmt, v, strings[v], ext->exts);
-                }
+            if (*(const char **)ext->substmts[u].storage) {
+                ypr_open(pctx->out, flag);
+                ypr_substmt(pctx, ext->substmts[u].stmt, 0, *(const char **)ext->substmts[u].storage, ext->exts);
             }
             break;
         case LY_STMT_MUST: {
@@ -2537,18 +2528,9 @@
             ypr_status(pctx, *(uint16_t *)ext->substmts[u].storage, ext->exts, flag);
             break;
         case LY_STMT_TYPE:
-            if (ext->substmts[u].cardinality < LY_STMT_CARD_SOME) {
-                if (*(const struct lysc_type **)ext->substmts[u].storage) {
-                    ypr_open(pctx->out, flag);
-                    yprc_type(pctx, *(const struct lysc_type **)ext->substmts[u].storage);
-                }
-            } else {
-                const struct lysc_type **types = *(const struct lysc_type ***)ext->substmts[u].storage;
-
-                LY_ARRAY_FOR(types, v) {
-                    ypr_open(pctx->out, flag);
-                    yprc_type(pctx, types[v]);
-                }
+            if (*(const struct lysc_type **)ext->substmts[u].storage) {
+                ypr_open(pctx->out, flag);
+                yprc_type(pctx, *(const struct lysc_type **)ext->substmts[u].storage);
             }
             break;
         /* TODO support other substatements */
diff --git a/src/schema_compile.c b/src/schema_compile.c
index 3fdb37d..5264095 100644
--- a/src/schema_compile.c
+++ b/src/schema_compile.c
@@ -140,17 +140,13 @@
 }
 
 LIBYANG_API_DEF LY_ERR
-lysc_ext_substmt(const struct lysc_ext_instance *ext, enum ly_stmt substmt, void **instance_p,
-        enum ly_stmt_cardinality *cardinality_p)
+lysc_ext_substmt(const struct lysc_ext_instance *ext, enum ly_stmt substmt, void **instance_p)
 {
     LY_ARRAY_COUNT_TYPE u;
 
     if (instance_p) {
         *instance_p = NULL;
     }
-    if (cardinality_p) {
-        *cardinality_p = 0;
-    }
 
     LY_ARRAY_FOR(ext->substmts, u) {
         if (LY_STMT_IS_DATA_NODE(substmt)) {
@@ -166,9 +162,6 @@
         }
 
         /* match */
-        if (cardinality_p) {
-            *cardinality_p = ext->substmts[u].cardinality;
-        }
         if (instance_p) {
             *instance_p = ext->substmts[u].storage;
         }
@@ -586,20 +579,14 @@
     case LY_STMT_PRESENCE:
     case LY_STMT_REFERENCE:
     case LY_STMT_UNITS: {
-        const char ***strs_p, **str_p;
+        const char **str_p;
 
-        if (substmt->cardinality < LY_STMT_CARD_SOME) {
-            /* single item */
-            str_p = substmt->storage;
-            if (*str_p) {
-                LOGVAL(ctx->ctx, LY_VCODE_DUPSTMT, stmt->stmt);
-                rc = LY_EVALID;
-                goto cleanup;
-            }
-        } else {
-            /* sized array */
-            strs_p = substmt->storage;
-            LY_ARRAY_NEW_GOTO(ctx->ctx, *strs_p, str_p, rc, cleanup);
+        /* single item */
+        str_p = substmt->storage;
+        if (*str_p) {
+            LOGVAL(ctx->ctx, LY_VCODE_DUPSTMT, stmt->stmt);
+            rc = LY_EVALID;
+            goto cleanup;
         }
 
         /* called instead of lysp_stmt_parse() to skip validation and not parse nested ext instances */
@@ -607,26 +594,14 @@
         break;
     }
     case LY_STMT_MUST: {
-        struct lysc_must **musts_p, **must_p, *must;
+        struct lysc_must **musts_p, *must;
 
         /* parse */
         LY_CHECK_GOTO(rc = lysp_stmt_parse(ctx, stmt, (void **)&restrs, NULL), cleanup);
 
-        if (substmt->cardinality < LY_STMT_CARD_SOME) {
-            /* single item */
-            must_p = substmt->storage;
-            if (*must_p) {
-                LOGVAL(ctx->ctx, LY_VCODE_DUPSTMT, stmt->stmt);
-                rc = LY_EVALID;
-                goto cleanup;
-            }
-            *must_p = calloc(1, sizeof **must_p);
-            must = *must_p;
-        } else {
-            /* sized array */
-            musts_p = substmt->storage;
-            LY_ARRAY_NEW_GOTO(ctx->ctx, *musts_p, must, rc, cleanup);
-        }
+        /* sized array */
+        musts_p = substmt->storage;
+        LY_ARRAY_NEW_GOTO(ctx->ctx, *musts_p, must, rc, cleanup);
 
         /* compile */
         LY_CHECK_GOTO(rc = lys_compile_must(ctx, restrs, must), cleanup);
@@ -644,45 +619,26 @@
         break;
     }
     case LY_STMT_STATUS:
-        if (substmt->cardinality > LY_STMT_CARD_MAND) {
-            /* only cardinality 0..1 and 1 */
-            goto not_supported;
-        }
         /* result needs to be a pointer to pointer */
         LY_CHECK_GOTO(rc = lysp_stmt_parse(ctx, stmt, &substmt->storage, NULL), cleanup);
         break;
 
     case LY_STMT_TYPEDEF:
-        if (substmt->cardinality < LY_STMT_CARD_SOME) {
-            /* single item */
-            if (*(struct lysp_tpdf **)substmt->storage) {
-                LOGVAL(ctx->ctx, LY_VCODE_DUPSTMT, stmt->stmt);
-                rc = LY_EVALID;
-                goto cleanup;
-            }
-        } /* else sized array */
-
         /* parse */
         LY_CHECK_GOTO(rc = lysp_stmt_parse(ctx, stmt, substmt->storage, NULL), cleanup);
         break;
 
     case LY_STMT_TYPE: {
-        struct lysc_type ***types_p, **type_p;
+        struct lysc_type **type_p;
         const uint16_t *flags = lys_compile_ext_instance_get_storage(ext, LY_STMT_STATUS);
         const char **units = (void *)lys_compile_ext_instance_get_storage(ext, LY_STMT_UNITS);
 
-        if (substmt->cardinality < LY_STMT_CARD_SOME) {
-            /* single item */
-            type_p = substmt->storage;
-            if (*type_p) {
-                LOGVAL(ctx->ctx, LY_VCODE_DUPSTMT, stmt->stmt);
-                rc = LY_EVALID;
-                goto cleanup;
-            }
-        } else {
-            /* sized array of pointers */
-            types_p = substmt->storage;
-            LY_ARRAY_NEW_GOTO(ctx->ctx, *types_p, type_p, rc, cleanup);
+        /* single item */
+        type_p = substmt->storage;
+        if (*type_p) {
+            LOGVAL(ctx->ctx, LY_VCODE_DUPSTMT, stmt->stmt);
+            rc = LY_EVALID;
+            goto cleanup;
         }
 
         LY_CHECK_GOTO(rc = lysp_stmt_parse(ctx, stmt, (void **)&ptype, NULL), cleanup);
@@ -693,10 +649,9 @@
     /* TODO support other substatements (parse stmt to lysp and then compile lysp to lysc),
         * also note that in many statements their extensions are not taken into account  */
     default:
-not_supported:
-        LOGVAL(ctx->ctx, LYVE_SYNTAX_YANG, "Statement \"%s\" in cardinality %s is not supported as an extension "
-                "(found in \"%s%s%s\") substatement.", stmt->stmt, ly_cardinality2str(substmt->cardinality),
-                ext_p->name, ext_p->argument ? " " : "", ext_p->argument ? ext_p->argument : "");
+        LOGVAL(ctx->ctx, LYVE_SYNTAX_YANG, "Statement \"%s\" is not supported as an extension "
+                "(found in \"%s%s%s\") substatement.", stmt->stmt, ext_p->name, ext_p->argument ? " " : "",
+                ext_p->argument ? ext_p->argument : "");
         rc = LY_EVALID;
         goto cleanup;
     }
@@ -716,7 +671,6 @@
     LY_ERR rc = LY_SUCCESS;
     LY_ARRAY_COUNT_TYPE u;
     struct lysp_stmt *stmt;
-    uint64_t stmt_counter;
 
     /* check for invalid substatements */
     for (stmt = ext_p->child; stmt; stmt = stmt->next) {
@@ -745,27 +699,15 @@
      * the order is important for some of the statements depending on others (e.g. type needs status and units) */
 
     LY_ARRAY_FOR(ext->substmts, u) {
-        stmt_counter = 0;
-
         for (stmt = ext_p->child; stmt; stmt = stmt->next) {
             if (ext->substmts[u].stmt != stmt->kw) {
                 continue;
             }
 
-            stmt_counter++;
             if ((rc = lys_compile_ext_instance_stmt(ctx, ext_p, ext, &ext->substmts[u], stmt, aug_target))) {
                 goto cleanup;
             }
         }
-
-        if (((ext->substmts[u].cardinality == LY_STMT_CARD_MAND) || (ext->substmts[u].cardinality == LY_STMT_CARD_SOME)) &&
-                !stmt_counter) {
-            LOGVAL(ctx->ctx, LYVE_SYNTAX_YANG, "Missing mandatory keyword \"%s\" as a child of \"%s%s%s\".",
-                    ly_stmt2str(ext->substmts[u].stmt), ext_p->name, ext_p->argument ? " " : "",
-                    ext_p->argument ? ext_p->argument : "");
-            rc = LY_EVALID;
-            goto cleanup;
-        }
     }
 
 cleanup:
diff --git a/src/schema_compile_node.c b/src/schema_compile_node.c
index a935907..0d2fe6d 100644
--- a/src/schema_compile_node.c
+++ b/src/schema_compile_node.c
@@ -2444,7 +2444,7 @@
 
         if (ctx->ext) {
             /* container matches all data nodes */
-            lysc_ext_substmt(ctx->ext, LY_STMT_CONTAINER, (void **)&list, NULL);
+            lysc_ext_substmt(ctx->ext, LY_STMT_CONTAINER, (void **)&list);
         } else if (node->nodetype == LYS_RPC) {
             list = (struct lysc_node **)&ctx->cur_mod->compiled->rpcs;
         } else if (node->nodetype == LYS_NOTIF) {
diff --git a/src/tree_schema.c b/src/tree_schema.c
index 3e6d5d2..345c5db 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -139,22 +139,6 @@
     }
 }
 
-LIBYANG_API_DEF const char *
-ly_cardinality2str(enum ly_stmt_cardinality card)
-{
-    switch (card) {
-    case LY_STMT_CARD_OPT:
-        return "0..1";
-    case LY_STMT_CARD_MAND:
-        return "1";
-    case LY_STMT_CARD_SOME:
-        return "1..n";
-    case LY_STMT_CARD_ANY:
-        return "0..n";
-    }
-
-    return NULL;
-}
 
 const char * const ly_devmod_list[] = {
     [LYS_DEV_NOT_SUPPORTED] = "not-supported",
@@ -288,7 +272,7 @@
         } else {
             /* top level data */
             if (ext) {
-                lysc_ext_substmt(ext, LY_STMT_CONTAINER /* matches all nodes */, (void **)&data_p, NULL);
+                lysc_ext_substmt(ext, LY_STMT_CONTAINER /* matches all nodes */, (void **)&data_p);
                 next = last = data_p ? *data_p : NULL;
             } else {
                 next = last = module->data;
@@ -321,7 +305,7 @@
         } else if (!action_flag) {
             action_flag = 1;
             if (ext) {
-                lysc_ext_substmt(ext, LY_STMT_RPC /* matches also actions */, (void **)&data_p, NULL);
+                lysc_ext_substmt(ext, LY_STMT_RPC /* matches also actions */, (void **)&data_p);
                 next = data_p ? *data_p : NULL;
             } else if (parent) {
                 next = (struct lysc_node *)lysc_node_actions(parent);
@@ -331,7 +315,7 @@
         } else if (!notif_flag) {
             notif_flag = 1;
             if (ext) {
-                lysc_ext_substmt(ext, LY_STMT_NOTIFICATION, (void **)&data_p, NULL);
+                lysc_ext_substmt(ext, LY_STMT_NOTIFICATION, (void **)&data_p);
                 next = data_p ? *data_p : NULL;
             } else if (parent) {
                 next = (struct lysc_node *)lysc_node_notifs(parent);
diff --git a/src/tree_schema_free.c b/src/tree_schema_free.c
index d35d8a4..21d7539 100644
--- a/src/tree_schema_free.c
+++ b/src/tree_schema_free.c
@@ -1405,47 +1405,28 @@
         case LY_STMT_ORGANIZATION:
         case LY_STMT_PRESENCE:
         case LY_STMT_REFERENCE:
-        case LY_STMT_UNITS:
-            if (substmts[u].cardinality < LY_STMT_CARD_SOME) {
-                /* single item */
-                const char *str = *((const char **)substmts[u].storage);
+        case LY_STMT_UNITS: {
+            /* single item */
+            const char *str = *((const char **)substmts[u].storage);
 
-                lydict_remove(ctx, str);
-            } else {
-                /* multiple items */
-                const char **strs = *((const char ***)substmts[u].storage);
-
-                FREE_STRINGS(ctx, strs);
-            }
+            lydict_remove(ctx, str);
             break;
-        case LY_STMT_MUST:
-            if (substmts[u].cardinality < LY_STMT_CARD_SOME) {
-                /* single item */
-                struct lysc_must *must = *((struct lysc_must **)substmts[u].storage);
+        }
+        case LY_STMT_MUST: {
+            /* multiple items */
+            struct lysc_must *musts = *((struct lysc_must **)substmts[u].storage);
 
-                lysc_must_free(&fctx, must);
-                free(must);
-            } else {
-                /* multiple items */
-                struct lysc_must *musts = *((struct lysc_must **)substmts[u].storage);
-
-                FREE_ARRAY(&fctx, musts, lysc_must_free);
-            }
+            FREE_ARRAY(&fctx, musts, lysc_must_free);
             break;
+        }
         case LY_STMT_IF_FEATURE: {
             struct lysc_iffeature *iff = *((struct lysc_iffeature **)substmts[u].storage);
 
             if (!iff) {
                 break;
             }
-            if (substmts[u].cardinality < LY_STMT_CARD_SOME) {
-                /* single item */
-                lysc_iffeature_free(&fctx, iff);
-                free(iff);
-            } else {
-                /* multiple items */
-                FREE_ARRAY(&fctx, iff, lysc_iffeature_free);
-            }
+            /* multiple items */
+            FREE_ARRAY(&fctx, iff, lysc_iffeature_free);
             break;
         }
         case LY_STMT_TYPEDEF: {
@@ -1458,26 +1439,16 @@
             FREE_ARRAY(&fctx, tpdf, lysp_tpdf_free);
             break;
         }
-        case LY_STMT_TYPE:
-            if (substmts[u].cardinality < LY_STMT_CARD_SOME) {
-                /* single item */
-                struct lysc_type *type = *((struct lysc_type **)substmts[u].storage);
+        case LY_STMT_TYPE: {
+            /* single item */
+            struct lysc_type *type = *((struct lysc_type **)substmts[u].storage);
 
-                if (!type) {
-                    break;
-                }
-                lysc_type_free(&fctx, type);
-            } else {
-                /* multiple items */
-                struct lysc_type **types = *((struct lysc_type ***)substmts[u].storage);
-
-                if (!types) {
-                    break;
-                }
-                FREE_ARRAY(&fctx, types, lysc_type2_free);
+            if (!type) {
+                break;
             }
+            lysc_type_free(&fctx, type);
             break;
-
+        }
         /* TODO other statements */
         default:
             LOGINT(ctx);