libyang REFACTOR rename sized array size to count

... because it reflects the fact that it may not
always (internally) be the size of the array.
diff --git a/src/common.h b/src/common.h
index 0c458a8..4ff5220 100644
--- a/src/common.h
+++ b/src/common.h
@@ -484,15 +484,15 @@
  */
 #define LY_ARRAY_NEW_RET(CTX, ARRAY, NEW_ITEM, RETVAL) \
         if (!(ARRAY)) { \
-            ARRAY = malloc(sizeof(LY_ARRAY_SIZE_TYPE) + sizeof *(ARRAY)); \
-            *((LY_ARRAY_SIZE_TYPE*)(ARRAY)) = 1; \
+            ARRAY = malloc(sizeof(LY_ARRAY_COUNT_TYPE) + sizeof *(ARRAY)); \
+            *((LY_ARRAY_COUNT_TYPE*)(ARRAY)) = 1; \
         } else { \
-            ++(*((LY_ARRAY_SIZE_TYPE*)(ARRAY) - 1)); \
-            ARRAY = ly_realloc(((LY_ARRAY_SIZE_TYPE*)(ARRAY) - 1), sizeof(LY_ARRAY_SIZE_TYPE) + (*((LY_ARRAY_SIZE_TYPE*)(ARRAY) - 1) * sizeof *(ARRAY))); \
+            ++(*((LY_ARRAY_COUNT_TYPE*)(ARRAY) - 1)); \
+            ARRAY = ly_realloc(((LY_ARRAY_COUNT_TYPE*)(ARRAY) - 1), sizeof(LY_ARRAY_COUNT_TYPE) + (*((LY_ARRAY_COUNT_TYPE*)(ARRAY) - 1) * sizeof *(ARRAY))); \
             LY_CHECK_ERR_RET(!(ARRAY), LOGMEM(CTX), RETVAL); \
         } \
-        ARRAY = (void*)((LY_ARRAY_SIZE_TYPE*)(ARRAY) + 1); \
-        (NEW_ITEM) = &(ARRAY)[*((LY_ARRAY_SIZE_TYPE*)(ARRAY) - 1) - 1]; \
+        ARRAY = (void*)((LY_ARRAY_COUNT_TYPE*)(ARRAY) + 1); \
+        (NEW_ITEM) = &(ARRAY)[*((LY_ARRAY_COUNT_TYPE*)(ARRAY) - 1) - 1]; \
         memset(NEW_ITEM, 0, sizeof *(NEW_ITEM))
 
 /**
@@ -509,15 +509,15 @@
  */
 #define LY_ARRAY_NEW_GOTO(CTX, ARRAY, NEW_ITEM, RET, GOTO) \
         if (!(ARRAY)) { \
-            ARRAY = malloc(sizeof(LY_ARRAY_SIZE_TYPE) + sizeof *(ARRAY)); \
-            *((LY_ARRAY_SIZE_TYPE*)(ARRAY)) = 1; \
+            ARRAY = malloc(sizeof(LY_ARRAY_COUNT_TYPE) + sizeof *(ARRAY)); \
+            *((LY_ARRAY_COUNT_TYPE*)(ARRAY)) = 1; \
         } else { \
-            ++(*((LY_ARRAY_SIZE_TYPE*)(ARRAY) - 1)); \
-            ARRAY = ly_realloc(((LY_ARRAY_SIZE_TYPE*)(ARRAY) - 1), sizeof(LY_ARRAY_SIZE_TYPE) + (*((LY_ARRAY_SIZE_TYPE*)(ARRAY) - 1) * sizeof *(ARRAY))); \
+            ++(*((LY_ARRAY_COUNT_TYPE*)(ARRAY) - 1)); \
+            ARRAY = ly_realloc(((LY_ARRAY_COUNT_TYPE*)(ARRAY) - 1), sizeof(LY_ARRAY_COUNT_TYPE) + (*((LY_ARRAY_COUNT_TYPE*)(ARRAY) - 1) * sizeof *(ARRAY))); \
             LY_CHECK_ERR_GOTO(!(ARRAY), LOGMEM(CTX); RET = LY_EMEM, GOTO); \
         } \
-        ARRAY = (void*)((LY_ARRAY_SIZE_TYPE*)(ARRAY) + 1); \
-        (NEW_ITEM) = &(ARRAY)[*((LY_ARRAY_SIZE_TYPE*)(ARRAY) - 1) - 1]; \
+        ARRAY = (void*)((LY_ARRAY_COUNT_TYPE*)(ARRAY) + 1); \
+        (NEW_ITEM) = &(ARRAY)[*((LY_ARRAY_COUNT_TYPE*)(ARRAY) - 1) - 1]; \
         memset(NEW_ITEM, 0, sizeof *(NEW_ITEM))
 
 /**
@@ -535,21 +535,21 @@
  */
 #define LY_ARRAY_CREATE_RET(CTX, ARRAY, SIZE, RETVAL) \
         if (ARRAY) { \
-            ARRAY = ly_realloc(((LY_ARRAY_SIZE_TYPE*)(ARRAY) - 1), sizeof(LY_ARRAY_SIZE_TYPE) + ((*((LY_ARRAY_SIZE_TYPE*)(ARRAY) - 1) + SIZE) * sizeof *(ARRAY))); \
+            ARRAY = ly_realloc(((LY_ARRAY_COUNT_TYPE*)(ARRAY) - 1), sizeof(LY_ARRAY_COUNT_TYPE) + ((*((LY_ARRAY_COUNT_TYPE*)(ARRAY) - 1) + SIZE) * sizeof *(ARRAY))); \
             LY_CHECK_ERR_RET(!(ARRAY), LOGMEM(CTX), RETVAL); \
-            ARRAY = (void*)((LY_ARRAY_SIZE_TYPE*)(ARRAY) + 1); \
-            memset(&(ARRAY)[*((LY_ARRAY_SIZE_TYPE*)(ARRAY) - 1)], 0, SIZE * sizeof *(ARRAY)); \
+            ARRAY = (void*)((LY_ARRAY_COUNT_TYPE*)(ARRAY) + 1); \
+            memset(&(ARRAY)[*((LY_ARRAY_COUNT_TYPE*)(ARRAY) - 1)], 0, SIZE * sizeof *(ARRAY)); \
         } else { \
-            ARRAY = calloc(1, sizeof(LY_ARRAY_SIZE_TYPE) + SIZE * sizeof *(ARRAY)); \
+            ARRAY = calloc(1, sizeof(LY_ARRAY_COUNT_TYPE) + SIZE * sizeof *(ARRAY)); \
             LY_CHECK_ERR_RET(!(ARRAY), LOGMEM(CTX), RETVAL); \
-            ARRAY = (void*)((LY_ARRAY_SIZE_TYPE*)(ARRAY) + 1); \
+            ARRAY = (void*)((LY_ARRAY_COUNT_TYPE*)(ARRAY) + 1); \
         }
 
 /**
  * @brief Allocate a ([sized array](@ref sizedarrays)) for the specified number of items.
  * If the ARRAY already exists, it is resized (space for SIZE items is added).
  *
- * Does not set the size information, it is supposed to be incremented via ::LY_ARRAY_INCREMENT
+ * Does not set the count information, it is supposed to be incremented via ::LY_ARRAY_INCREMENT
  * when the items are filled.
  *
  * @param[in] CTX libyang context for logging.
@@ -561,20 +561,20 @@
  */
 #define LY_ARRAY_CREATE_GOTO(CTX, ARRAY, SIZE, RET, GOTO) \
         if (ARRAY) { \
-            ARRAY = ly_realloc(((LY_ARRAY_SIZE_TYPE*)(ARRAY) - 1), sizeof(LY_ARRAY_SIZE_TYPE) + ((*((LY_ARRAY_SIZE_TYPE*)(ARRAY) - 1) + (SIZE)) * sizeof *(ARRAY))); \
+            ARRAY = ly_realloc(((LY_ARRAY_COUNT_TYPE*)(ARRAY) - 1), sizeof(LY_ARRAY_COUNT_TYPE) + ((*((LY_ARRAY_COUNT_TYPE*)(ARRAY) - 1) + (SIZE)) * sizeof *(ARRAY))); \
             LY_CHECK_ERR_GOTO(!(ARRAY), LOGMEM(CTX); RET = LY_EMEM, GOTO); \
-            ARRAY = (void*)((LY_ARRAY_SIZE_TYPE*)(ARRAY) + 1); \
-            memset(&(ARRAY)[*((LY_ARRAY_SIZE_TYPE*)(ARRAY) - 1)], 0, (SIZE) * sizeof *(ARRAY)); \
+            ARRAY = (void*)((LY_ARRAY_COUNT_TYPE*)(ARRAY) + 1); \
+            memset(&(ARRAY)[*((LY_ARRAY_COUNT_TYPE*)(ARRAY) - 1)], 0, (SIZE) * sizeof *(ARRAY)); \
         } else { \
-            ARRAY = calloc(1, sizeof(LY_ARRAY_SIZE_TYPE) + (SIZE) * sizeof *(ARRAY)); \
+            ARRAY = calloc(1, sizeof(LY_ARRAY_COUNT_TYPE) + (SIZE) * sizeof *(ARRAY)); \
             LY_CHECK_ERR_GOTO(!(ARRAY), LOGMEM(CTX); RET = LY_EMEM, GOTO); \
-            ARRAY = (void*)((LY_ARRAY_SIZE_TYPE*)(ARRAY) + 1); \
+            ARRAY = (void*)((LY_ARRAY_COUNT_TYPE*)(ARRAY) + 1); \
         }
 
 /**
  * @brief Resize a ([sized array](@ref sizedarrays)) to the the specified number of items.
  *
- * Does not change the size information, it is supposed to be incremented via ::LY_ARRAY_INCREMENT
+ * Does not change the count information, it is supposed to be incremented via ::LY_ARRAY_INCREMENT
  * when the items are filled.
  *
  * @param[in] CTX libyang context for logging.
@@ -585,9 +585,9 @@
  * @param[in] RETVAL Return value for the case of error (memory allocation failure).
  */
 #define LY_ARRAY_RESIZE_ERR_RET(CTX, ARRAY, SIZE, ERR, RETVAL) \
-        ARRAY = ly_realloc(((LY_ARRAY_SIZE_TYPE*)(ARRAY) - 1), sizeof(LY_ARRAY_SIZE_TYPE) + ((SIZE) * sizeof *(ARRAY))); \
+        ARRAY = ly_realloc(((LY_ARRAY_COUNT_TYPE*)(ARRAY) - 1), sizeof(LY_ARRAY_COUNT_TYPE) + ((SIZE) * sizeof *(ARRAY))); \
         LY_CHECK_ERR_RET(!(ARRAY), LOGMEM(CTX); ERR, RETVAL); \
-        ARRAY = (void*)((LY_ARRAY_SIZE_TYPE*)(ARRAY) + 1);
+        ARRAY = (void*)((LY_ARRAY_COUNT_TYPE*)(ARRAY) + 1);
 
 /**
  * @brief Increment the items counter in a ([sized array](@ref sizedarrays)).
@@ -598,7 +598,7 @@
  * @param[in] ARRAY Pointer to the array to affect.
  */
 #define LY_ARRAY_INCREMENT(ARRAY) \
-        ++(*((LY_ARRAY_SIZE_TYPE*)(ARRAY) - 1))
+        ++(*((LY_ARRAY_COUNT_TYPE*)(ARRAY) - 1))
 
 /**
  * @brief Decrement the items counter in a ([sized array](@ref sizedarrays)).
@@ -609,7 +609,7 @@
  * @param[in] ARRAY Pointer to the array to affect.
  */
 #define LY_ARRAY_DECREMENT(ARRAY) \
-        --(*((LY_ARRAY_SIZE_TYPE*)(ARRAY) - 1))
+        --(*((LY_ARRAY_COUNT_TYPE*)(ARRAY) - 1))
 
 /**
  * @brief Free the space allocated for the ([sized array](@ref sizedarrays)).
@@ -619,7 +619,7 @@
  * @param[in] ARRAY A ([sized array](@ref sizedarrays)) to be freed.
  */
 #define LY_ARRAY_FREE(ARRAY) \
-        if (ARRAY){free((LY_ARRAY_SIZE_TYPE*)(ARRAY) - 1);}
+        if (ARRAY){free((LY_ARRAY_COUNT_TYPE*)(ARRAY) - 1);}
 
 /**
  * @brief Insert item into linked list.
diff --git a/src/context.c b/src/context.c
index a0f432c..7e498ee 100644
--- a/src/context.c
+++ b/src/context.c
@@ -488,7 +488,7 @@
     const struct lys_module *mod;
     struct lysp_include *inc;
     uint32_t v;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     assert(submodule);
 
@@ -529,7 +529,7 @@
             mod->latest_revision = 1;
         }
         if (mod->parsed && mod->parsed->includes) {
-            for (LY_ARRAY_SIZE_TYPE u = 0; u < LY_ARRAY_SIZE(mod->parsed->includes); ++u) {
+            for (LY_ARRAY_COUNT_TYPE u = 0; u < LY_ARRAY_COUNT(mod->parsed->includes); ++u) {
                 if (mod->parsed->includes[u].submodule->latest_revision == 2) {
                     mod->parsed->includes[u].submodule->latest_revision = 1;
                 }
@@ -541,7 +541,7 @@
 static LY_ERR
 ylib_feature(struct lyd_node *parent, const struct lys_module *cur_mod)
 {
-    LY_ARRAY_SIZE_TYPE i;
+    LY_ARRAY_COUNT_TYPE i;
     struct lyd_node *node;
 
     if (!cur_mod->implemented) {
@@ -564,7 +564,7 @@
 static LY_ERR
 ylib_deviation(struct lyd_node *parent, const struct lys_module *cur_mod, int bis)
 {
-    LY_ARRAY_SIZE_TYPE i;
+    LY_ARRAY_COUNT_TYPE i;
     struct lyd_node *node;
     struct lys_module *mod;
 
@@ -591,7 +591,7 @@
 static LY_ERR
 ylib_submodules(struct lyd_node *parent, const struct lys_module *cur_mod, int bis)
 {
-    LY_ARRAY_SIZE_TYPE i;
+    LY_ARRAY_COUNT_TYPE i;
     struct lyd_node *node, *cont;
     struct lysp_submodule *submod;
     int ret;
diff --git a/src/lyb.h b/src/lyb.h
index 5e14a03..4fd75d5 100644
--- a/src/lyb.h
+++ b/src/lyb.h
@@ -35,7 +35,7 @@
         size_t position;
         uint8_t inner_chunks;
     } *subtrees;
-    LY_ARRAY_SIZE_TYPE subtree_size;
+    LY_ARRAY_COUNT_TYPE subtree_size;
 
     size_t byte_count;  /**< printed/parsed bytes */
     const struct ly_ctx *ctx;
@@ -87,7 +87,7 @@
  */
 
 /* just a shortcut */
-#define LYB_LAST_SUBTREE(lybctx) lybctx->subtrees[LY_ARRAY_SIZE(lybctx->subtrees) - 1]
+#define LYB_LAST_SUBTREE(lybctx) lybctx->subtrees[LY_ARRAY_COUNT(lybctx->subtrees) - 1]
 
 /* struct lyd_lyb_subtree allocation step */
 #define LYB_SUBTREE_STEP 4
diff --git a/src/parser_lyb.c b/src/parser_lyb.c
index b2aca77..56b1b2b 100644
--- a/src/parser_lyb.c
+++ b/src/parser_lyb.c
@@ -44,7 +44,7 @@
 lyb_read(uint8_t *buf, size_t count, struct lyd_lyb_ctx *lybctx)
 {
     int parsed = 0;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     struct lyd_lyb_subtree *empty;
     size_t to_read;
     uint8_t meta_buf[LYB_META_BYTES];
@@ -220,13 +220,13 @@
 lyb_read_start_subtree(struct lyd_lyb_ctx *lybctx)
 {
     uint8_t meta_buf[LYB_META_BYTES];
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     if (!lybctx->subtrees) {
         assert(lybctx->subtree_size == 0);
         u = 0;
     } else {
-        u = LY_ARRAY_SIZE(lybctx->subtrees);
+        u = LY_ARRAY_COUNT(lybctx->subtrees);
     }
     if (u == lybctx->subtree_size) {
         LY_ARRAY_CREATE_RET(lybctx->ctx, lybctx->subtrees, u + LYB_SUBTREE_STEP, LY_EMEM);
@@ -946,7 +946,7 @@
 {
     LY_ERR ret;
     uint32_t count;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     /* read model count */
     lyb_read_number(&count, sizeof count, 2, lybctx);
diff --git a/src/parser_stmt.c b/src/parser_stmt.c
index 9ad5ca2..f208a1b 100644
--- a/src/parser_stmt.c
+++ b/src/parser_stmt.c
@@ -72,7 +72,7 @@
  */
 static LY_ERR
 lysp_stmt_ext(struct lys_parser_ctx *ctx, const struct lysp_stmt *stmt, LYEXT_SUBSTMT insubstmt,
-              LY_ARRAY_SIZE_TYPE insubstmt_index, struct lysp_ext_instance **exts)
+              LY_ARRAY_COUNT_TYPE insubstmt_index, struct lysp_ext_instance **exts)
 {
     struct lysp_ext_instance *e;
 
@@ -167,7 +167,7 @@
 
         switch (kw) {
         case LY_STMT_EXTENSION_INSTANCE:
-            LY_CHECK_RET(lysp_stmt_ext(ctx, child, substmt, LY_ARRAY_SIZE(*texts) - 1, exts));
+            LY_CHECK_RET(lysp_stmt_ext(ctx, child, substmt, LY_ARRAY_COUNT(*texts) - 1, exts));
             break;
         default:
             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), lyext_substmt2str(substmt));
diff --git a/src/parser_yang.c b/src/parser_yang.c
index 93231a8..8652a40 100644
--- a/src/parser_yang.c
+++ b/src/parser_yang.c
@@ -815,7 +815,7 @@
  */
 static LY_ERR
 parse_ext(struct lys_yang_parser_ctx *ctx, const char **data, const char *ext_name, int ext_name_len, LYEXT_SUBSTMT insubstmt,
-          LY_ARRAY_SIZE_TYPE insubstmt_index, struct lysp_ext_instance **exts)
+          LY_ARRAY_COUNT_TYPE insubstmt_index, struct lysp_ext_instance **exts)
 {
     LY_ERR ret = LY_SUCCESS;
     char *buf, *word;
@@ -1239,7 +1239,7 @@
     YANG_READ_SUBSTMT_FOR(ctx, data, kw, word, word_len, ret,) {
         switch (kw) {
         case LY_STMT_EXTENSION_INSTANCE:
-            LY_CHECK_RET(parse_ext(ctx, data, word, word_len, substmt, LY_ARRAY_SIZE(*texts) - 1, exts));
+            LY_CHECK_RET(parse_ext(ctx, data, word, word_len, substmt, LY_ARRAY_COUNT(*texts) - 1, exts));
             break;
         default:
             LOGVAL_PARSER(ctx, LY_VCODE_INCHILDSTMT, ly_stmt2str(kw), lyext_substmt2str(substmt));
diff --git a/src/parser_yin.c b/src/parser_yin.c
index dc48f6d..dfaebd6 100644
--- a/src/parser_yin.c
+++ b/src/parser_yin.c
@@ -631,7 +631,7 @@
 {
     const char **value;
     LY_ARRAY_NEW_RET(ctx->xmlctx->ctx, *values, value, LY_EMEM);
-    LY_ARRAY_SIZE_TYPE index = LY_ARRAY_SIZE(*values) - 1;
+    LY_ARRAY_COUNT_TYPE index = LY_ARRAY_COUNT(*values) - 1;
     struct yin_subelement subelems[1] = {
                                             {LY_STMT_EXTENSION_INSTANCE, &index, 0}
                                         };
@@ -2832,7 +2832,7 @@
             /* call responsible function */
             case LY_STMT_EXTENSION_INSTANCE:
                 ret = yin_parse_extension_instance(ctx, kw2lyext_substmt(current_element),
-                                                   (subelem->dest) ? *((LY_ARRAY_SIZE_TYPE*)subelem->dest) : 0, exts);
+                                                   (subelem->dest) ? *((LY_ARRAY_COUNT_TYPE*)subelem->dest) : 0, exts);
                 break;
             case LY_STMT_ACTION:
             case LY_STMT_RPC:
@@ -3049,7 +3049,7 @@
 }
 
 LY_ERR
-yin_parse_extension_instance(struct lys_yin_parser_ctx *ctx, LYEXT_SUBSTMT subelem, LY_ARRAY_SIZE_TYPE subelem_index,
+yin_parse_extension_instance(struct lys_yin_parser_ctx *ctx, LYEXT_SUBSTMT subelem, LY_ARRAY_COUNT_TYPE subelem_index,
                              struct lysp_ext_instance **exts)
 {
     struct lysp_ext_instance *e;
diff --git a/src/parser_yin.h b/src/parser_yin.h
index 3302aa3..7ab6c86 100644
--- a/src/parser_yin.h
+++ b/src/parser_yin.h
@@ -177,7 +177,7 @@
  *
  * @return LY_ERR values.
  */
-LY_ERR yin_parse_extension_instance(struct lys_yin_parser_ctx *ctx, LYEXT_SUBSTMT subelem, LY_ARRAY_SIZE_TYPE subelem_index,
+LY_ERR yin_parse_extension_instance(struct lys_yin_parser_ctx *ctx, LYEXT_SUBSTMT subelem, LY_ARRAY_COUNT_TYPE subelem_index,
                                     struct lysp_ext_instance **exts);
 
 /**
diff --git a/src/path.c b/src/path.c
index 0d5f3f3..f4829e3 100644
--- a/src/path.c
+++ b/src/path.c
@@ -462,7 +462,7 @@
         for (key = lysc_node_children(ctx_node, 0); key && (key->flags & LYS_KEY); key = key->next) {
             ++key_count;
         }
-        if (LY_ARRAY_SIZE(*predicates) != key_count) {
+        if (LY_ARRAY_COUNT(*predicates) != key_count) {
             /* names (keys) are unique - it was checked when parsing */
             LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_XPATH, "Predicate missing for a key of %s \"%s\" in path.",
                    lys_nodetype2str(ctx_node->nodetype), ctx_node->name);
@@ -766,10 +766,10 @@
 }
 
 LY_ERR
-ly_path_eval_partial(const struct ly_path *path, const struct lyd_node *start, LY_ARRAY_SIZE_TYPE *path_idx,
+ly_path_eval_partial(const struct ly_path *path, const struct lyd_node *start, LY_ARRAY_COUNT_TYPE *path_idx,
                      struct lyd_node **match)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     struct lyd_node *prev_node = NULL, *node, *target;
     uint64_t pos;
 
@@ -888,18 +888,18 @@
 LY_ERR
 ly_path_dup(const struct ly_ctx *ctx, const struct ly_path *path, struct ly_path **dup)
 {
-    LY_ARRAY_SIZE_TYPE u, v;
+    LY_ARRAY_COUNT_TYPE u, v;
 
     if (!path) {
         return LY_SUCCESS;
     }
 
-    LY_ARRAY_CREATE_RET(ctx, *dup, LY_ARRAY_SIZE(path), LY_EMEM);
+    LY_ARRAY_CREATE_RET(ctx, *dup, LY_ARRAY_COUNT(path), LY_EMEM);
     LY_ARRAY_FOR(path, u) {
         LY_ARRAY_INCREMENT(*dup);
         (*dup)[u].node = path[u].node;
         if (path[u].predicates) {
-            LY_ARRAY_CREATE_RET(ctx, (*dup)[u].predicates, LY_ARRAY_SIZE(path[u].predicates), LY_EMEM);
+            LY_ARRAY_CREATE_RET(ctx, (*dup)[u].predicates, LY_ARRAY_COUNT(path[u].predicates), LY_EMEM);
             (*dup)[u].pred_type = path[u].pred_type;
             LY_ARRAY_FOR(path[u].predicates, v) {
                 struct ly_path_predicate *pred = &path[u].predicates[v];
@@ -931,7 +931,7 @@
 ly_path_predicates_free(const struct ly_ctx *ctx, enum ly_path_pred_type pred_type, const struct lysc_node *llist,
                         struct ly_path_predicate *predicates)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     if (!predicates) {
         return;
@@ -957,7 +957,7 @@
 void
 ly_path_free(const struct ly_ctx *ctx, struct ly_path *path)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     LY_ARRAY_FOR(path, u) {
         ly_path_predicates_free(ctx, path[u].pred_type, path[u].node, path[u].predicates);
diff --git a/src/path.h b/src/path.h
index 3c2df75..a60fdc6 100644
--- a/src/path.h
+++ b/src/path.h
@@ -189,7 +189,7 @@
  * @return LY_SUCCESS when the last node in the path was found,
  * @return LY_ERR on another error.
  */
-LY_ERR ly_path_eval_partial(const struct ly_path *path, const struct lyd_node *start, LY_ARRAY_SIZE_TYPE *path_idx,
+LY_ERR ly_path_eval_partial(const struct ly_path *path, const struct lyd_node *start, LY_ARRAY_COUNT_TYPE *path_idx,
                             struct lyd_node **match);
 
 /**
diff --git a/src/plugins_exts_metadata.c b/src/plugins_exts_metadata.c
index b2d405f..0c116af 100644
--- a/src/plugins_exts_metadata.c
+++ b/src/plugins_exts_metadata.c
@@ -45,7 +45,7 @@
 {
     struct lyext_metadata *annotation;
     struct lysc_module *mod_c;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     /* annotations can appear only at the top level of a YANG module or submodule */
     if (c_ext->parent_type != LYEXT_PAR_MODULE) {
diff --git a/src/plugins_exts_nacm.c b/src/plugins_exts_nacm.c
index fc0c5da..5f131b1 100644
--- a/src/plugins_exts_nacm.c
+++ b/src/plugins_exts_nacm.c
@@ -34,7 +34,7 @@
 {
     struct lysc_node *parent = NULL, *iter;
     struct lysc_ext_instance *inherited;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     static const uint8_t nacm_deny_all = 1;
     static const uint8_t nacm_deny_write = 2;
diff --git a/src/plugins_types.c b/src/plugins_types.c
index def80c8..92fdfb1 100644
--- a/src/plugins_types.c
+++ b/src/plugins_types.c
@@ -163,7 +163,7 @@
     const char *start, *stop;
     struct lyd_value_prefix *prefixes = NULL;
     const struct lys_module *mod;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     for (stop = start = value; (size_t)(stop - value) < value_len; start = stop) {
         size_t bytes;
@@ -349,7 +349,7 @@
 {
     LY_ERR ret = LY_SUCCESS;
     int rc;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     char *errmsg;
     pcre2_match_data *match_data = NULL;
 
@@ -392,7 +392,7 @@
 ly_type_validate_range(LY_DATA_TYPE basetype, struct lysc_range *range, int64_t value, const char *strval,
                        struct ly_err_item **err)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     char *errmsg = NULL;
 
     LY_ARRAY_FOR(range->parts, u) {
@@ -410,7 +410,7 @@
             } else if ((uint64_t)value <= range->parts[u].max_u64) {
                 /* inside the range */
                 return LY_SUCCESS;
-            } else if (u == LY_ARRAY_SIZE(range->parts) - 1) {
+            } else if (u == LY_ARRAY_COUNT(range->parts) - 1) {
                 /* we have the last range part, so the value is out of bounds */
                 if (range->emsg) {
                     errmsg = strdup(range->emsg);
@@ -433,7 +433,7 @@
             } else if (value < range->parts[u].max_64) {
                 /* inside the range */
                 return LY_SUCCESS;
-            } else if (u == LY_ARRAY_SIZE(range->parts) - 1) {
+            } else if (u == LY_ARRAY_COUNT(range->parts) - 1) {
                 /* we have the last range part, so the value is out of bounds */
                 if (range->emsg) {
                     errmsg = strdup(range->emsg);
@@ -886,7 +886,7 @@
     size_t buf_size = 0;
     char *buf = NULL;
     size_t index;
-    LY_ARRAY_SIZE_TYPE u, v;
+    LY_ARRAY_COUNT_TYPE u, v;
     char *errmsg = NULL;
     struct lysc_type_bits *type_bits = (struct lysc_type_bits*)type;
     int iscanonical = 1;
@@ -924,7 +924,7 @@
                 /* check that the bit is not disabled */
                 LY_ARRAY_FOR(type_bits->bits[u].iffeatures, v) {
                     if (lysc_iffeature_value(&type_bits->bits[u].iffeatures[v]) == LY_ENOT) {
-                        asprintf(&errmsg, "Bit \"%s\" is disabled by its %" LY_PRI_ARRAY_SIZE_TYPE ". if-feature condition.",
+                        asprintf(&errmsg, "Bit \"%s\" is disabled by its %" LY_PRI_ARRAY_COUNT_TYPE ". if-feature condition.",
                                  type_bits->bits[u].name, v + 1);
                         goto error;
                     }
@@ -1027,9 +1027,9 @@
 static LY_ERR
 ly_type_dup_bits(const struct ly_ctx *ctx, const struct lyd_value *original, struct lyd_value *dup)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
-    LY_ARRAY_CREATE_RET(ctx, dup->bits_items, LY_ARRAY_SIZE(original->bits_items), LY_EMEM);
+    LY_ARRAY_CREATE_RET(ctx, dup->bits_items, LY_ARRAY_COUNT(original->bits_items), LY_EMEM);
     LY_ARRAY_FOR(original->bits_items, u) {
         LY_ARRAY_INCREMENT(dup->bits_items);
         dup->bits_items[u] = original->bits_items[u];
@@ -1064,7 +1064,7 @@
                    const void *UNUSED(context_node), const struct lyd_node *UNUSED(tree),
                    struct lyd_value *storage, const char **canonized, struct ly_err_item **err)
 {
-    LY_ARRAY_SIZE_TYPE u, v;
+    LY_ARRAY_COUNT_TYPE u, v;
     char *errmsg = NULL;
     struct lysc_type_enum *type_enum = (struct lysc_type_enum*)type;
 
@@ -1080,7 +1080,7 @@
             /* check that the enumeration value is not disabled */
             LY_ARRAY_FOR(type_enum->enums[u].iffeatures, v) {
                 if (lysc_iffeature_value(&type_enum->enums[u].iffeatures[v]) == LY_ENOT) {
-                    asprintf(&errmsg, "Enumeration \"%s\" is disabled by its %" LY_PRI_ARRAY_SIZE_TYPE ". if-feature condition.",
+                    asprintf(&errmsg, "Enumeration \"%s\" is disabled by its %" LY_PRI_ARRAY_COUNT_TYPE ". if-feature condition.",
                              type_enum->enums[u].name, v + 1);
                     goto error;
                 }
@@ -1233,7 +1233,7 @@
 API LY_ERR
 ly_type_identity_isderived(struct lysc_ident *base, struct lysc_ident *der)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     LY_ARRAY_FOR(base->derived, u) {
         if (der == base->derived[u]) {
@@ -1262,7 +1262,7 @@
     size_t id_len, prefix_len;
     char *errmsg = NULL;
     const struct lys_module *mod;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     struct lysc_ident *ident, *identities;
 
     if (options & LY_TYPE_OPTS_SECOND_CALL) {
@@ -1302,7 +1302,7 @@
             break;
         }
     }
-    if (u == LY_ARRAY_SIZE(identities)) {
+    if (u == LY_ARRAY_COUNT(identities)) {
         /* no match */
         asprintf(&errmsg, "Invalid identityref \"%.*s\" value - identity not found.", (int)value_len, value);
         goto error;
@@ -1320,7 +1320,7 @@
             break;
         }
     }
-    if (u == LY_ARRAY_SIZE(type_ident->bases)) {
+    if (u == LY_ARRAY_COUNT(type_ident->bases)) {
         /* no match */
         asprintf(&errmsg, "Invalid identityref \"%.*s\" value - identity not accepted by the type specification.", (int)value_len, value);
         goto error;
@@ -1399,7 +1399,7 @@
 ly_type_stored_prefixes_clb(const struct ly_ctx *UNUSED(ctx), const char *prefix, size_t prefix_len, void *private)
 {
     struct lyd_value_prefix *prefixes = (struct lyd_value_prefix*)private;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     LY_ARRAY_FOR(prefixes, u) {
         if (!ly_strncmp(prefixes[u].prefix, prefix, prefix_len)) {
@@ -1424,7 +1424,7 @@
     struct lysc_type_instanceid *type_inst = (struct lysc_type_instanceid *)type;
     char *errmsg = NULL;
     struct lyd_value_prefix *prefixes = NULL;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     struct ly_path *path = NULL;
     struct ly_set predicates = {0};
     struct lyxp_expr *exp = NULL;
@@ -1549,11 +1549,11 @@
 static LY_ERR
 ly_type_compare_instanceid(const struct lyd_value *val1, const struct lyd_value *val2)
 {
-    LY_ARRAY_SIZE_TYPE u, v;
+    LY_ARRAY_COUNT_TYPE u, v;
 
     if (val1 == val2) {
         return LY_SUCCESS;
-    } else if (!val1->target || !val2->target || LY_ARRAY_SIZE(val1->target) != LY_ARRAY_SIZE(val2->target)) {
+    } else if (!val1->target || !val2->target || LY_ARRAY_COUNT(val1->target) != LY_ARRAY_COUNT(val2->target)) {
         return LY_ENOT;
     }
 
@@ -1562,7 +1562,7 @@
         struct ly_path *s2 = &val2->target[u];
 
         if (s1->node != s2->node || (s1->pred_type != s2->pred_type) ||
-                (s1->predicates && LY_ARRAY_SIZE(s1->predicates) != LY_ARRAY_SIZE(s2->predicates))) {
+                (s1->predicates && LY_ARRAY_COUNT(s1->predicates) != LY_ARRAY_COUNT(s2->predicates))) {
             return LY_ENOT;
         }
         if (s1->predicates) {
@@ -1607,7 +1607,7 @@
 ly_type_print_instanceid(const struct lyd_value *value, LYD_FORMAT format, ly_clb_get_prefix get_prefix, void *printer,
                          int *dynamic)
 {
-    LY_ARRAY_SIZE_TYPE u, v;
+    LY_ARRAY_COUNT_TYPE u, v;
     char *result = NULL;
 
     if (!value->target && value->canonical_cache) {
@@ -1960,7 +1960,7 @@
                     struct lyd_value *storage, const char **canonized, struct ly_err_item **err)
 {
     LY_ERR ret;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     struct lysc_type_union *type_u = (struct lysc_type_union*)type;
     struct lyd_value_subvalue *subvalue;
     char *errmsg = NULL;
@@ -2016,7 +2016,7 @@
             *err = NULL;
         }
 
-        if (u == LY_ARRAY_SIZE(type_u->types)) {
+        if (u == LY_ARRAY_COUNT(type_u->types)) {
             asprintf(&errmsg, "Invalid union value \"%.*s\" - no matching subtype found.", (int)value_len, value);
             goto error;
         }
@@ -2094,12 +2094,12 @@
 static LY_ERR
 ly_type_dup_union(const struct ly_ctx *ctx, const struct lyd_value *original, struct lyd_value *dup)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     dup->subvalue = calloc(1, sizeof *dup->subvalue);
     LY_CHECK_ERR_RET(!dup->subvalue, LOGMEM(ctx), LY_EMEM);
     if (original->subvalue->prefixes) {
-        LY_ARRAY_CREATE_RET(ctx, dup->subvalue->prefixes, LY_ARRAY_SIZE(original->subvalue->prefixes), LY_EMEM);
+        LY_ARRAY_CREATE_RET(ctx, dup->subvalue->prefixes, LY_ARRAY_COUNT(original->subvalue->prefixes), LY_EMEM);
         LY_ARRAY_FOR(original->subvalue->prefixes, u) {
             LY_ARRAY_INCREMENT(dup->subvalue->prefixes);
             dup->subvalue->prefixes[u].mod = original->subvalue->prefixes[u].mod;
@@ -2122,7 +2122,7 @@
 static void
 ly_type_free_union(const struct ly_ctx *ctx, struct lyd_value *value)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     if (value->subvalue) {
         if (value->subvalue->value) {
diff --git a/src/printer.c b/src/printer.c
index b324030..b215267 100644
--- a/src/printer.c
+++ b/src/printer.c
@@ -77,7 +77,7 @@
     const struct lysc_node_leaf *leaf;
     const struct lysc_node_leaflist *llist;
     const struct lyd_node_term *term;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     assert(node->schema->nodetype & LYD_NODE_TERM);
     term = (const struct lyd_node_term *)node;
diff --git a/src/printer_lyb.c b/src/printer_lyb.c
index ba2ad27..b7794a1 100644
--- a/src/printer_lyb.c
+++ b/src/printer_lyb.c
@@ -225,7 +225,7 @@
 static LY_ERR
 lyb_write(struct ly_out *out, const uint8_t *buf, size_t count, struct lyd_lyb_ctx *lybctx)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     struct lyd_lyb_subtree *full, *iter;
     ssize_t r, to_write;
     uint8_t meta_buf[LYB_META_BYTES];
@@ -339,13 +339,13 @@
 lyb_write_start_subtree(struct ly_out *out, struct lyd_lyb_ctx *lybctx)
 {
     ssize_t r;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     if (!lybctx->subtrees) {
         assert(lybctx->subtree_size == 0);
         u = 0;
     } else {
-        u = LY_ARRAY_SIZE(lybctx->subtrees);
+        u = LY_ARRAY_COUNT(lybctx->subtrees);
     }
     if (u == lybctx->subtree_size) {
         LY_ARRAY_CREATE_RET(lybctx->ctx, lybctx->subtrees, u + LYB_SUBTREE_STEP, LY_EMEM);
@@ -357,7 +357,7 @@
     LYB_LAST_SUBTREE(lybctx).inner_chunks = 0;
 
     /* another inner chunk */
-    for (u = 0; u < LY_ARRAY_SIZE(lybctx->subtrees) - 1; ++u) {
+    for (u = 0; u < LY_ARRAY_COUNT(lybctx->subtrees) - 1; ++u) {
         if (lybctx->subtrees[u].inner_chunks == LYB_INCHUNK_MAX) {
             LOGINT(lybctx->ctx);
             return -1;
@@ -489,7 +489,7 @@
 lyb_print_data_models(struct ly_out *out, const struct lyd_node *root, struct lyd_lyb_ctx *lybctx)
 {
     struct ly_set *set;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     LY_ERR ret = LY_SUCCESS;
     struct lys_module *mod;
     const struct lyd_node *node;
@@ -593,14 +593,14 @@
 lyb_print_opaq_prefixes(struct ly_out *out, const struct ly_prefix *prefs, struct lyd_lyb_ctx *lybctx)
 {
     uint8_t count;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
-    if (prefs && (LY_ARRAY_SIZE(prefs) > UINT8_MAX)) {
+    if (prefs && (LY_ARRAY_COUNT(prefs) > UINT8_MAX)) {
         LOGERR(lybctx->ctx, LY_EINT, "Maximum supported number of prefixes is %u.", UINT8_MAX);
         return LY_EINT;
     }
 
-    count = prefs ? LY_ARRAY_SIZE(prefs) : 0;
+    count = prefs ? LY_ARRAY_COUNT(prefs) : 0;
 
     /* write number of prefixes on 1 byte */
     LY_CHECK_RET(lyb_write(out, &count, 1, lybctx));
@@ -875,7 +875,7 @@
 static LY_ERR
 lyb_print_schema_hash(struct ly_out *out, struct lysc_node *schema, struct hash_table **sibling_ht, struct lyd_lyb_ctx *lybctx)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     uint32_t i;
     LYB_HASH hash;
     struct lyd_lyb_sib_ht *sib_ht;
@@ -1002,7 +1002,7 @@
 {
     LY_ERR ret = LY_SUCCESS;
     uint8_t zero = 0;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     struct hash_table *top_sibling_ht = NULL;
     const struct lys_module *prev_mod = NULL;
     struct lyd_lyb_ctx lybctx = {0};
diff --git a/src/printer_xml.c b/src/printer_xml.c
index 7191d84..71e53c0 100644
--- a/src/printer_xml.c
+++ b/src/printer_xml.c
@@ -233,7 +233,7 @@
 {
     const struct ly_attr *attr;
     const char *pref;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     LY_LIST_FOR(node->attr, attr) {
         pref = NULL;
@@ -449,7 +449,7 @@
 {
     LY_ERR ret;
     struct lyd_node *child;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     LY_CHECK_RET(xml_print_opaq_open(ctx, node));
 
diff --git a/src/printer_yang.c b/src/printer_yang.c
index 2b64651..25012b2 100755
--- a/src/printer_yang.c
+++ b/src/printer_yang.c
@@ -221,15 +221,15 @@
  */
 static void
 yprp_extension_instances(struct ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index,
-                               struct lysp_ext_instance *ext, int *flag, LY_ARRAY_SIZE_TYPE count)
+                               struct lysp_ext_instance *ext, int *flag, LY_ARRAY_COUNT_TYPE count)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     struct lysp_stmt *stmt;
     int child_presence;
     const char *argument;
 
     if (!count && ext) {
-        count = LY_ARRAY_SIZE(ext);
+        count = LY_ARRAY_COUNT(ext);
     }
     LY_ARRAY_FOR(ext, u) {
         if (!count) {
@@ -288,12 +288,12 @@
  */
 static void
 yprc_extension_instances(struct ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index,
-                                 struct lysc_ext_instance *ext, int *flag, LY_ARRAY_SIZE_TYPE count)
+                                 struct lysc_ext_instance *ext, int *flag, LY_ARRAY_COUNT_TYPE count)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     if (!count && ext) {
-        count = LY_ARRAY_SIZE(ext);
+        count = LY_ARRAY_COUNT(ext);
     }
     LY_ARRAY_FOR(ext, u) {
         if (!count) {
@@ -312,7 +312,7 @@
 static void
 ypr_substmt(struct ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index, const char *text, void *ext)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int extflag = 0;
 
     if (!text) {
@@ -446,7 +446,7 @@
 static void
 yprp_iffeatures(struct ypr_ctx *ctx, const char **iff, struct lysp_ext_instance *exts, int *flag)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int extflag;
 
     LY_ARRAY_FOR(iff, u) {
@@ -514,7 +514,7 @@
 static void
 yprc_iffeatures(struct ypr_ctx *ctx, struct lysc_iffeature *iff, struct lysc_ext_instance *exts, int *flag)
 {
-    LY_ARRAY_SIZE_TYPE u, v;
+    LY_ARRAY_COUNT_TYPE u, v;
     int extflag;
 
     LY_ARRAY_FOR(iff, u) {
@@ -544,7 +544,7 @@
 yprp_extension(struct ypr_ctx *ctx, const struct lysp_ext *ext)
 {
     int flag = 0, flag2 = 0;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     ly_print(ctx->out, "%*sextension %s", INDENT, ext->name);
     LEVEL++;
@@ -559,12 +559,12 @@
         LEVEL++;
         if (ext->exts) {
             u = -1;
-            while ((u = lysp_ext_instance_iter(ext->exts, u + 1, LYEXT_SUBSTMT_ARGUMENT)) != LY_ARRAY_SIZE(ext->exts)) {
+            while ((u = lysp_ext_instance_iter(ext->exts, u + 1, LYEXT_SUBSTMT_ARGUMENT)) != LY_ARRAY_COUNT(ext->exts)) {
                 yprp_extension_instances(ctx, LYEXT_SUBSTMT_ARGUMENT, 0, &ext->exts[u], &flag2, 1);
             }
         }
         if ((ext->flags & LYS_YINELEM_MASK) ||
-                (ext->exts && lysp_ext_instance_iter(ext->exts, 0, LYEXT_SUBSTMT_YINELEM) != LY_ARRAY_SIZE(ext->exts))) {
+                (ext->exts && lysp_ext_instance_iter(ext->exts, 0, LYEXT_SUBSTMT_YINELEM) != LY_ARRAY_COUNT(ext->exts))) {
             ypr_open(ctx->out, &flag2);
             ypr_substmt(ctx, LYEXT_SUBSTMT_YINELEM, 0, (ext->flags & LYS_YINELEM_TRUE) ? "true" : "false", ext->exts);
         }
@@ -616,7 +616,7 @@
 yprp_identity(struct ypr_ctx *ctx, const struct lysp_ident *ident)
 {
     int flag = 0;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     ly_print(ctx->out, "\n%*sidentity %s", INDENT, ident->name);
     LEVEL++;
@@ -641,7 +641,7 @@
 yprc_identity(struct ypr_ctx *ctx, const struct lysc_ident *ident)
 {
     int flag = 0;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     ly_print(ctx->out, "\n%*sidentity %s", INDENT, ident->name);
     LEVEL++;
@@ -733,7 +733,7 @@
 yprc_range(struct ypr_ctx *ctx, const struct lysc_range *range, LY_DATA_TYPE basetype, int *flag)
 {
     int inner_flag = 0;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     if (!range) {
         return;
@@ -857,7 +857,7 @@
 static void
 yprp_enum(struct ypr_ctx *ctx, const struct lysp_type_enum *items, LY_DATA_TYPE type, int *flag)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int inner_flag;
 
     LY_ARRAY_FOR(items, u) {
@@ -891,7 +891,7 @@
 static void
 yprp_type(struct ypr_ctx *ctx, const struct lysp_type *type)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int flag = 0;
 
     ly_print(ctx->out, "%*stype %s", INDENT, type->name);
@@ -947,7 +947,7 @@
 static void
 yprc_type(struct ypr_ctx *ctx, const struct lysc_type *type)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int flag = 0;
 
     ly_print(ctx->out, "%*stype %s", INDENT, lys_datatype2str(type->basetype));
@@ -1097,7 +1097,7 @@
 static void
 yprp_grouping(struct ypr_ctx *ctx, const struct lysp_grp *grp)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int flag = 0;
     struct lysp_node *data;
 
@@ -1137,7 +1137,7 @@
 static void
 yprp_inout(struct ypr_ctx *ctx, const struct lysp_action_inout *inout, int *flag)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     struct lysp_node *data;
 
     if (!inout->nodetype) {
@@ -1171,7 +1171,7 @@
 static void
 yprc_inout(struct ypr_ctx *ctx, const struct lysc_action *action, const struct lysc_action_inout *inout, int *flag)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     struct lysc_node *data;
 
     if (!inout->data) {
@@ -1201,7 +1201,7 @@
 static void
 yprp_notification(struct ypr_ctx *ctx, const struct lysp_notif *notif)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int flag = 0;
     struct lysp_node *data;
 
@@ -1242,7 +1242,7 @@
 static void
 yprc_notification(struct ypr_ctx *ctx, const struct lysc_notif *notif)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int flag = 0;
     struct lysc_node *data;
 
@@ -1275,7 +1275,7 @@
 static void
 yprp_action(struct ypr_ctx *ctx, const struct lysp_action *action)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int flag = 0;
 
     LYOUT_CHECK(ctx->out);
@@ -1343,7 +1343,7 @@
 static void
 yprc_node_common1(struct ypr_ctx *ctx, const struct lysc_node *node, int *flag)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     ly_print(ctx->out, "%*s%s %s%s", INDENT, lys_nodetype2str(node->nodetype), node->name, flag ? "" : " {\n");
     LEVEL++;
@@ -1382,7 +1382,7 @@
 static void
 yprp_container(struct ypr_ctx *ctx, const struct lysp_node *node)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int flag = 0;
     struct lysp_node *child;
     struct lysp_node_container *cont = (struct lysp_node_container *)node;
@@ -1431,7 +1431,7 @@
 static void
 yprc_container(struct ypr_ctx *ctx, const struct lysc_node *node)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int flag = 0;
     struct lysc_node *child;
     struct lysc_node_container *cont = (struct lysc_node_container *)node;
@@ -1561,7 +1561,7 @@
 static void
 yprp_leaf(struct ypr_ctx *ctx, const struct lysp_node *node)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     struct lysp_node_leaf *leaf = (struct lysp_node_leaf *)node;
 
     yprp_node_common1(ctx, node, NULL);
@@ -1582,7 +1582,7 @@
 static void
 yprc_leaf(struct ypr_ctx *ctx, const struct lysc_node *node)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     struct lysc_node_leaf *leaf = (struct lysc_node_leaf *)node;
 
     yprc_node_common1(ctx, node, NULL);
@@ -1606,7 +1606,7 @@
 static void
 yprp_leaflist(struct ypr_ctx *ctx, const struct lysp_node *node)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     struct lysp_node_leaflist *llist = (struct lysp_node_leaflist *)node;
 
     yprp_node_common1(ctx, node, NULL);
@@ -1648,7 +1648,7 @@
 static void
 yprc_leaflist(struct ypr_ctx *ctx, const struct lysc_node *node)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     struct lysc_node_leaflist *llist = (struct lysc_node_leaflist *)node;
 
     yprc_node_common1(ctx, node, NULL);
@@ -1684,7 +1684,7 @@
 static void
 yprp_list(struct ypr_ctx *ctx, const struct lysp_node *node)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int flag = 0;
     struct lysp_node *child;
     struct lysp_node_list *list = (struct lysp_node_list *)node;
@@ -1756,7 +1756,7 @@
 static void
 yprc_list(struct ypr_ctx *ctx, const struct lysc_node *node)
 {
-    LY_ARRAY_SIZE_TYPE u, v;
+    LY_ARRAY_COUNT_TYPE u, v;
     int flag = 0;
     struct lysc_node *child;
     struct lysc_node_list *list = (struct lysc_node_list *)node;
@@ -1822,7 +1822,7 @@
 static void
 yprp_refine(struct ypr_ctx *ctx, struct lysp_refine *refine)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int flag = 0;
 
     ly_print(ctx->out, "%*srefine \"%s\"", INDENT, refine->nodeid);
@@ -1872,7 +1872,7 @@
 static void
 yprp_augment(struct ypr_ctx *ctx, const struct lysp_augment *aug)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     struct lysp_node *child;
 
     ly_print(ctx->out, "%*saugment \"%s\" {\n", INDENT, aug->nodeid);
@@ -1905,7 +1905,7 @@
 static void
 yprp_uses(struct ypr_ctx *ctx, const struct lysp_node *node)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int flag = 0;
     struct lysp_node_uses *uses = (struct lysp_node_uses *)node;
 
@@ -1929,7 +1929,7 @@
 static void
 yprp_anydata(struct ypr_ctx *ctx, const struct lysp_node *node)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int flag = 0;
     struct lysp_node_anydata *any = (struct lysp_node_anydata *)node;
 
@@ -1949,7 +1949,7 @@
 static void
 yprc_anydata(struct ypr_ctx *ctx, const struct lysc_node *node)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int flag = 0;
     struct lysc_node_anydata *any = (struct lysc_node_anydata *)node;
 
@@ -2035,7 +2035,7 @@
 static void
 yprp_deviation(struct ypr_ctx *ctx, const struct lysp_deviation *deviation)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     struct lysp_deviate_add *add;
     struct lysp_deviate_rpl *rpl;
     struct lysp_deviate_del *del;
@@ -2180,7 +2180,7 @@
 LY_ERR
 yang_print_parsed(struct ly_out *out, const struct lys_module *module)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     struct lysp_node *data;
     struct lysp_module *modp = module->parsed;
     struct ypr_ctx ctx_ = {.out = out, .level = 0, .module = module, .schema = YPR_PARSED}, *ctx = &ctx_;
@@ -2316,7 +2316,7 @@
 LY_ERR
 yang_print_compiled(struct ly_out *out, const struct lys_module *module, int options)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     struct lysc_node *data;
     struct lysc_module *modc = module->compiled;
     struct ypr_ctx ctx_ = {.out = out, .level = 0, .module = module, .options = options}, *ctx = &ctx_;
diff --git a/src/printer_yin.c b/src/printer_yin.c
index 4589496..8a1139d 100644
--- a/src/printer_yin.c
+++ b/src/printer_yin.c
@@ -41,7 +41,7 @@
 #define INDENT (LEVEL)*2,""          /**< indentation parameters for printer functions */
 
 static void yprp_extension_instances(struct ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index,
-                               struct lysp_ext_instance *ext, int *flag, LY_ARRAY_SIZE_TYPE count);
+                               struct lysp_ext_instance *ext, int *flag, LY_ARRAY_COUNT_TYPE count);
 
 static void
 ypr_open(struct ypr_ctx *ctx, const char *elem_name, const char *attr_name, const char *attr_value,  int flag)
@@ -94,7 +94,7 @@
 static void
 ypr_substmt(struct ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index, const char *text, void *ext)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int extflag = 0;
 
     if (!text) {
@@ -227,7 +227,7 @@
 static void
 yprp_iffeatures(struct ypr_ctx *ctx, const char **iff, struct lysp_ext_instance *exts, int *flag)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int extflag;
 
     LY_ARRAY_FOR(iff, u) {
@@ -253,7 +253,7 @@
 yprp_extension(struct ypr_ctx *ctx, const struct lysp_ext *ext)
 {
     int flag = 0, flag2 = 0;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     ypr_open(ctx, "extension", "name", ext->name, flag);
     LEVEL++;
@@ -270,13 +270,13 @@
         LEVEL++;
         if (ext->exts) {
             u = -1;
-            while ((u = lysp_ext_instance_iter(ext->exts, u + 1, LYEXT_SUBSTMT_ARGUMENT)) != LY_ARRAY_SIZE(ext->exts)) {
+            while ((u = lysp_ext_instance_iter(ext->exts, u + 1, LYEXT_SUBSTMT_ARGUMENT)) != LY_ARRAY_COUNT(ext->exts)) {
                 ypr_close_parent(ctx, &flag2);
                 yprp_extension_instances(ctx, LYEXT_SUBSTMT_ARGUMENT, 0, &ext->exts[u], &flag2, 1);
             }
         }
         if ((ext->flags & LYS_YINELEM_MASK) ||
-                (ext->exts && lysp_ext_instance_iter(ext->exts, 0, LYEXT_SUBSTMT_YINELEM) != LY_ARRAY_SIZE(ext->exts))) {
+                (ext->exts && lysp_ext_instance_iter(ext->exts, 0, LYEXT_SUBSTMT_YINELEM) != LY_ARRAY_COUNT(ext->exts))) {
             ypr_close_parent(ctx, &flag2);
             ypr_substmt(ctx, LYEXT_SUBSTMT_YINELEM, 0, (ext->flags & LYS_YINELEM_TRUE) ? "true" : "false", ext->exts);
         }
@@ -312,7 +312,7 @@
 yprp_identity(struct ypr_ctx *ctx, const struct lysp_ident *ident)
 {
     int flag = 0;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     ypr_open(ctx, "identity", "name", ident->name, flag);
     LEVEL++;
@@ -394,7 +394,7 @@
 static void
 yprp_enum(struct ypr_ctx *ctx, const struct lysp_type_enum *items, LY_DATA_TYPE type, int *flag)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int inner_flag;
     (void)flag;
 
@@ -432,7 +432,7 @@
 static void
 yprp_type(struct ypr_ctx *ctx, const struct lysp_type *type)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int flag = 0;
 
     if (!ctx || !type) {
@@ -513,7 +513,7 @@
 static void
 yprp_grouping(struct ypr_ctx *ctx, const struct lysp_grp *grp)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int flag = 0;
     struct lysp_node *data;
 
@@ -554,7 +554,7 @@
 static void
 yprp_inout(struct ypr_ctx *ctx, const struct lysp_action_inout *inout, int *flag)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     struct lysp_node *data;
 
     if (!inout->nodetype) {
@@ -588,7 +588,7 @@
 static void
 yprp_notification(struct ypr_ctx *ctx, const struct lysp_notif *notif)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int flag = 0;
     struct lysp_node *data;
 
@@ -630,7 +630,7 @@
 static void
 yprp_action(struct ypr_ctx *ctx, const struct lysp_action *action)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int flag = 0;
 
     LYOUT_CHECK(ctx->out);
@@ -687,7 +687,7 @@
 static void
 yprp_container(struct ypr_ctx *ctx, const struct lysp_node *node)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int flag = 0;
     struct lysp_node *child;
     struct lysp_node_container *cont = (struct lysp_node_container *)node;
@@ -781,7 +781,7 @@
 static void
 yprp_leaf(struct ypr_ctx *ctx, const struct lysp_node *node)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     struct lysp_node_leaf *leaf = (struct lysp_node_leaf *)node;
 
     int flag = 1;
@@ -803,7 +803,7 @@
 static void
 yprp_leaflist(struct ypr_ctx *ctx, const struct lysp_node *node)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     struct lysp_node_leaflist *llist = (struct lysp_node_leaflist *)node;
     int flag = 1;
 
@@ -846,7 +846,7 @@
 static void
 yprp_list(struct ypr_ctx *ctx, const struct lysp_node *node)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int flag = 0;
     struct lysp_node *child;
     struct lysp_node_list *list = (struct lysp_node_list *)node;
@@ -920,7 +920,7 @@
 static void
 yprp_refine(struct ypr_ctx *ctx, struct lysp_refine *refine)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int flag = 0;
 
     ypr_open(ctx, "refine", "target-node", refine->nodeid, flag);
@@ -970,7 +970,7 @@
 static void
 yprp_augment(struct ypr_ctx *ctx, const struct lysp_augment *aug)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     struct lysp_node *child;
 
     ypr_open(ctx, "augment", "target-node", aug->nodeid, 1);
@@ -1003,7 +1003,7 @@
 static void
 yprp_uses(struct ypr_ctx *ctx, const struct lysp_node *node)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int flag = 0;
     struct lysp_node_uses *uses = (struct lysp_node_uses *)node;
 
@@ -1027,7 +1027,7 @@
 static void
 yprp_anydata(struct ypr_ctx *ctx, const struct lysp_node *node)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int flag = 0;
     struct lysp_node_anydata *any = (struct lysp_node_anydata *)node;
 
@@ -1083,7 +1083,7 @@
 static void
 yprp_deviation(struct ypr_ctx *ctx, const struct lysp_deviation *deviation)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     struct lysp_deviate_add *add;
     struct lysp_deviate_rpl *rpl;
     struct lysp_deviate_del *del;
@@ -1226,7 +1226,7 @@
 static void
 ypr_xmlns(struct ypr_ctx *ctx, const struct lys_module *module, unsigned int indent)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     ly_print(ctx->out, "%*sxmlns=\"%s\"", indent + INDENT, YIN_NS_URI);
     ly_print(ctx->out, "\n%*sxmlns:%s=\"%s\"", indent + INDENT, module->prefix, module->ns);
@@ -1351,16 +1351,16 @@
  */
 static void
 yprp_extension_instances(struct ypr_ctx *ctx, LYEXT_SUBSTMT substmt, uint8_t substmt_index,
-                               struct lysp_ext_instance *ext, int *flag, LY_ARRAY_SIZE_TYPE count)
+                               struct lysp_ext_instance *ext, int *flag, LY_ARRAY_COUNT_TYPE count)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     char *str;
     struct lysp_stmt *stmt;
     const char *argument;
     const char *ext_argument;
 
     if (!count && ext) {
-        count = LY_ARRAY_SIZE(ext);
+        count = LY_ARRAY_COUNT(ext);
     }
     LY_ARRAY_FOR(ext, u) {
         if (!count) {
diff --git a/src/tree.h b/src/tree.h
index e63cfc1..11df43d 100644
--- a/src/tree.h
+++ b/src/tree.h
@@ -34,14 +34,14 @@
 /**
  * @brief Type (i.e. size) of the [sized array](@ref sizedarrays)'s size counter.
  *
- * To print the value via a print format, use LY_PRI_ARRAY_SIZE_TYPE specifier.
+ * To print the value via a print format, use LY_PRI_ARRAY_COUNT_TYPE specifier.
  */
-#define LY_ARRAY_SIZE_TYPE uint64_t
+#define LY_ARRAY_COUNT_TYPE uint64_t
 
 /**
  * @brief Printing format specifier macro for LY_ARRAY_SIZE_TYPE values.
  */
-#define LY_PRI_ARRAY_SIZE_TYPE PRIu64
+#define LY_PRI_ARRAY_COUNT_TYPE PRIu64
 
 /**
  * @brief Macro selector for other LY_ARRAY_* macros, do not use directly!
@@ -59,7 +59,7 @@
  */
 #define LY_ARRAY_FOR_ITER(ARRAY, TYPE, ITER) \
     for (ITER = ARRAY; \
-         (ARRAY) && ((void*)ITER - (void*)ARRAY)/(sizeof(TYPE)) < (*((LY_ARRAY_SIZE_TYPE*)(ARRAY) - 1)); \
+         (ARRAY) && ((void*)ITER - (void*)ARRAY)/(sizeof(TYPE)) < (*((LY_ARRAY_COUNT_TYPE*)(ARRAY) - 1)); \
          ITER = (void*)((TYPE*)ITER + 1))
 
 /**
@@ -74,15 +74,15 @@
  */
 #define LY_ARRAY_FOR_INDEX(ARRAY, INDEX) \
     for (INDEX = 0; \
-         ARRAY && INDEX < (*((LY_ARRAY_SIZE_TYPE*)(ARRAY) - 1)); \
+         ARRAY && INDEX < (*((LY_ARRAY_COUNT_TYPE*)(ARRAY) - 1)); \
          ++INDEX)
 
 /**
- * @brief Get a number of records in the ARRAY.
+ * @brief Get the number of records in the ARRAY.
  *
  * Does not check if array exists!
  */
-#define LY_ARRAY_SIZE(ARRAY) (*((LY_ARRAY_SIZE_TYPE*)(ARRAY) - 1))
+#define LY_ARRAY_COUNT(ARRAY) (*((LY_ARRAY_COUNT_TYPE*)(ARRAY) - 1))
 
 /**
  * @brief Sized-array iterator (for-loop).
@@ -98,7 +98,7 @@
  *
  *     LY_ARRAY_FOR(ARRAY, INDEX)
  *
- * The ARRAY is again a sized-array to go through, the INDEX is a variable (LY_ARRAY_SIZE_TYPE) for storing iterating ARRAY's index
+ * The ARRAY is again a sized-array to go through, the INDEX is a variable (LY_ARRAY_COUNT_TYPE) for storing iterating ARRAY's index
  * to access the items of ARRAY in the loops. This functionality is provided by LY_ARRAY_FOR_INDEX macro.
  */
 #define LY_ARRAY_FOR(ARRAY, ...) LY_ARRAY_SELECT(__VA_ARGS__, LY_ARRAY_FOR_ITER, LY_ARRAY_FOR_INDEX)(ARRAY, __VA_ARGS__)
diff --git a/src/tree_data.c b/src/tree_data.c
index 7fb5d58..dee3471 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -538,7 +538,7 @@
 {
     LY_ERR ret = LY_SUCCESS;
     struct lyd_node *list = NULL, *key;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     assert((schema->nodetype == LYS_LIST) && !(schema->flags & LYS_KEYLESS));
 
@@ -1072,7 +1072,7 @@
     struct ly_path *p = NULL;
     struct lyd_node *nparent = NULL, *nnode = NULL, *node = NULL, *cur_parent;
     const struct lysc_node *schema;
-    LY_ARRAY_SIZE_TYPE path_idx = 0;
+    LY_ARRAY_COUNT_TYPE path_idx = 0;
     struct ly_path_predicate *pred;
 
     LY_CHECK_ARG_RET(ctx, parent || ctx, path, (path[0] == '/') || parent, LY_EINVAL);
@@ -1090,17 +1090,17 @@
                                         options & LYD_NEWOPT_OUTPUT ? LY_PATH_OPER_OUTPUT : LY_PATH_OPER_INPUT,
                                         LY_PATH_TARGET_MANY, lydjson_resolve_prefix, NULL, LYD_JSON, &p), cleanup);
 
-    schema = p[LY_ARRAY_SIZE(p) - 1].node;
-    if ((schema->nodetype == LYS_LIST) && (p[LY_ARRAY_SIZE(p) - 1].pred_type == LY_PATH_PREDTYPE_NONE)
+    schema = p[LY_ARRAY_COUNT(p) - 1].node;
+    if ((schema->nodetype == LYS_LIST) && (p[LY_ARRAY_COUNT(p) - 1].pred_type == LY_PATH_PREDTYPE_NONE)
             && !(options & LYD_NEWOPT_OPAQ)) {
         LOGVAL(ctx, LY_VLOG_NONE, NULL, LYVE_XPATH, "Predicate missing for %s \"%s\" in path.",
                lys_nodetype2str(schema->nodetype), schema->name);
         ret = LY_EINVAL;
         goto cleanup;
-    } else if ((schema->nodetype == LYS_LEAFLIST) && (p[LY_ARRAY_SIZE(p) - 1].pred_type == LY_PATH_PREDTYPE_NONE)) {
+    } else if ((schema->nodetype == LYS_LEAFLIST) && (p[LY_ARRAY_COUNT(p) - 1].pred_type == LY_PATH_PREDTYPE_NONE)) {
         /* parse leafref value into a predicate, if not defined in the path */
-        p[LY_ARRAY_SIZE(p) - 1].pred_type = LY_PATH_PREDTYPE_LEAFLIST;
-        LY_ARRAY_NEW_GOTO(ctx, p[LY_ARRAY_SIZE(p) - 1].predicates, pred, ret, cleanup);
+        p[LY_ARRAY_COUNT(p) - 1].pred_type = LY_PATH_PREDTYPE_LEAFLIST;
+        LY_ARRAY_NEW_GOTO(ctx, p[LY_ARRAY_COUNT(p) - 1].predicates, pred, ret, cleanup);
 
         if (!value) {
             value = "";
@@ -1135,7 +1135,7 @@
             ++path_idx;
         } else if (ret == LY_ENOTFOUND) {
             /* we will create the nodes from top-level, default behavior (absolute path), or from the parent (relative path) */
-            if (lysc_data_parent(p[LY_ARRAY_SIZE(p) - 1].node)) {
+            if (lysc_data_parent(p[LY_ARRAY_COUNT(p) - 1].node)) {
                 node = parent;
             }
         } else {
@@ -1145,7 +1145,7 @@
     }
 
     /* create all the non-existing nodes in a loop */
-    for (; path_idx < LY_ARRAY_SIZE(p); ++path_idx) {
+    for (; path_idx < LY_ARRAY_COUNT(p); ++path_idx) {
         cur_parent = node;
         schema = p[path_idx].node;
 
@@ -1717,7 +1717,7 @@
     LY_ERR ret;
     struct lysc_ext_instance *ant = NULL;
     struct lyd_meta *mt, *last;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     assert((parent || meta) && mod);
 
@@ -2044,7 +2044,7 @@
     LY_ERR ret;
     int len;
     struct lyd_node *dup = NULL;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     LY_CHECK_ARG_RET(NULL, node, LY_EINVAL);
 
@@ -2106,7 +2106,7 @@
             opaq->prefix.ns = lydict_insert(LYD_NODE_CTX(node), orig->prefix.ns, 0);
         }
         if (orig->val_prefs) {
-            LY_ARRAY_CREATE_GOTO(LYD_NODE_CTX(node), opaq->val_prefs, LY_ARRAY_SIZE(orig->val_prefs), ret, error);
+            LY_ARRAY_CREATE_GOTO(LYD_NODE_CTX(node), opaq->val_prefs, LY_ARRAY_COUNT(orig->val_prefs), ret, error);
             LY_ARRAY_FOR(orig->val_prefs, u) {
                 opaq->val_prefs[u].pref = lydict_insert(LYD_NODE_CTX(node), orig->val_prefs[u].pref, 0);
                 opaq->val_prefs[u].ns = lydict_insert(LYD_NODE_CTX(node), orig->val_prefs[u].ns, 0);
@@ -2594,7 +2594,7 @@
 {
     struct lyd_diff_userord *item;
     const struct lyd_node *iter, **node;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     LY_ARRAY_FOR(*userord, u) {
         if ((*userord)[u].schema == schema) {
@@ -2675,12 +2675,12 @@
 
     /* find user-ordered first position */
     if (first) {
-        for (first_pos = second_pos; first_pos < LY_ARRAY_SIZE(userord_item->inst); ++first_pos) {
+        for (first_pos = second_pos; first_pos < LY_ARRAY_COUNT(userord_item->inst); ++first_pos) {
             if (userord_item->inst[first_pos] == first) {
                 break;
             }
         }
-        assert(first_pos < LY_ARRAY_SIZE(userord_item->inst));
+        assert(first_pos < LY_ARRAY_COUNT(userord_item->inst));
     }
 
     /* learn operation first */
@@ -2771,20 +2771,20 @@
      */
     if (*op == LYD_DIFF_OP_CREATE) {
         /* insert the instance */
-        LY_ARRAY_RESIZE_ERR_RET(schema->module->ctx, userord_item->inst, LY_ARRAY_SIZE(userord_item->inst) + 1,
+        LY_ARRAY_RESIZE_ERR_RET(schema->module->ctx, userord_item->inst, LY_ARRAY_COUNT(userord_item->inst) + 1,
                                 ;, LY_EMEM);
-        if (second_pos < LY_ARRAY_SIZE(userord_item->inst)) {
+        if (second_pos < LY_ARRAY_COUNT(userord_item->inst)) {
             memmove(userord_item->inst + second_pos + 1, userord_item->inst + second_pos,
-                    (LY_ARRAY_SIZE(userord_item->inst) - second_pos) * sizeof *userord_item->inst);
+                    (LY_ARRAY_COUNT(userord_item->inst) - second_pos) * sizeof *userord_item->inst);
         }
         LY_ARRAY_INCREMENT(userord_item->inst);
         userord_item->inst[second_pos] = second;
 
     } else if (*op == LYD_DIFF_OP_DELETE) {
         /* remove the instance */
-        if (first_pos + 1 < LY_ARRAY_SIZE(userord_item->inst)) {
+        if (first_pos + 1 < LY_ARRAY_COUNT(userord_item->inst)) {
             memmove(userord_item->inst + first_pos, userord_item->inst + first_pos + 1,
-                    (LY_ARRAY_SIZE(userord_item->inst) - first_pos - 1) * sizeof *userord_item->inst);
+                    (LY_ARRAY_COUNT(userord_item->inst) - first_pos - 1) * sizeof *userord_item->inst);
         }
         LY_ARRAY_DECREMENT(userord_item->inst);
 
@@ -2944,7 +2944,7 @@
     struct lyd_node *match_second, *match_first;
     int nosiblings = 0;
     struct lyd_diff_userord *userord = NULL;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     enum lyd_diff_op op;
     const char *orig_default;
     char *orig_value, *key, *value, *orig_key;
@@ -3691,7 +3691,7 @@
     struct ly_path_predicate *predicates = NULL;
     enum ly_path_pred_type pred_type = 0;
     struct lyd_value val = {0};
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     LY_CHECK_ARG_RET(NULL, schema, LY_EINVAL);
 
@@ -3743,7 +3743,7 @@
                 }
             }
 
-            if (u < LY_ARRAY_SIZE(predicates)) {
+            if (u < LY_ARRAY_COUNT(predicates)) {
                 /* not a match */
                 continue;
             }
diff --git a/src/tree_data_free.c b/src/tree_data_free.c
index d47e19c..e4da1b3 100644
--- a/src/tree_data_free.c
+++ b/src/tree_data_free.c
@@ -70,7 +70,7 @@
 ly_free_attr(const struct ly_ctx *ctx, struct ly_attr *attr, int recursive)
 {
     struct ly_attr *iter;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     LY_CHECK_ARG_RET(NULL, ctx, );
     if (!attr) {
@@ -120,7 +120,7 @@
 void
 ly_free_val_prefs(const struct ly_ctx *ctx, struct ly_prefix *val_prefs)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     LY_ARRAY_FOR(val_prefs, u) {
         FREE_STRING(ctx, val_prefs[u].pref);
diff --git a/src/tree_data_helpers.c b/src/tree_data_helpers.c
index aa7fd63..599a5bc 100644
--- a/src/tree_data_helpers.c
+++ b/src/tree_data_helpers.c
@@ -249,7 +249,7 @@
 int
 lyb_has_schema_model(const struct lysc_node *sibling, const struct lys_module **models)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     LY_ARRAY_FOR(models, u) {
         if (sibling->module == models[u]) {
diff --git a/src/tree_schema.c b/src/tree_schema.c
index bdaff3c..c2fc6bb 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -47,7 +47,7 @@
     int action_flag = 0, notif_flag = 0;
     const struct lysc_action *actions;
     const struct lysc_notif *notifs;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     LY_CHECK_ARG_RET(NULL, parent || module, NULL);
 
@@ -92,7 +92,7 @@
                 break;
             }
         }
-        if (u + 1 < LY_ARRAY_SIZE(actions)) {
+        if (u + 1 < LY_ARRAY_COUNT(actions)) {
             next = (struct lysc_node*)(&actions[u + 1]);
         }
         goto repeat;
@@ -108,7 +108,7 @@
                 break;
             }
         }
-        if (u + 1 < LY_ARRAY_SIZE(notifs)) {
+        if (u + 1 < LY_ARRAY_COUNT(notifs)) {
             next = (struct lysc_node*)(&notifs[u + 1]);
         }
         goto repeat;
@@ -498,7 +498,7 @@
 lys_feature_change(const struct lys_module *mod, const char *name, int value)
 {
     int all = 0;
-    LY_ARRAY_SIZE_TYPE u, disabled_count;
+    LY_ARRAY_COUNT_TYPE u, disabled_count;
     uint32_t changed_count;
     struct lysc_feature *f, **df;
     struct lysc_iffeature *iff;
@@ -528,7 +528,7 @@
     changed_count = 0;
 
 run:
-    for (disabled_count = u = 0; u < LY_ARRAY_SIZE(mod->compiled->features); ++u) {
+    for (disabled_count = u = 0; u < LY_ARRAY_COUNT(mod->compiled->features); ++u) {
         f = &mod->compiled->features[u];
         if (all || !strcmp(f->name, name)) {
             if ((value && (f->flags & LYS_FENABLED)) || (!value && !(f->flags & LYS_FENABLED))) {
@@ -587,7 +587,7 @@
         if (changed_count == changed->count) {
             /* no change in last run -> not able to enable all ... */
             /* ... print errors */
-            for (u = 0; disabled_count && u < LY_ARRAY_SIZE(mod->compiled->features); ++u) {
+            for (u = 0; disabled_count && u < LY_ARRAY_COUNT(mod->compiled->features); ++u) {
                 if (!(mod->compiled->features[u].flags & LYS_FENABLED)) {
                     LOGERR(ctx, LY_EDENIED,
                            "Feature \"%s\" cannot be enabled since it is disabled by its if-feature condition(s).",
@@ -660,13 +660,13 @@
 {
     struct lysc_feature *f;
     struct lysc_module *mod;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     LY_CHECK_ARG_RET(NULL, module, module->compiled, feature, -1);
     mod = module->compiled;
 
     /* search for the specified feature */
-    for (u = 0; u < LY_ARRAY_SIZE(mod->features); ++u) {
+    for (u = 0; u < LY_ARRAY_COUNT(mod->features); ++u) {
         f = &mod->features[u];
         if (!strcmp(f->name, feature)) {
             if (f->flags & LYS_FENABLED) {
@@ -684,7 +684,7 @@
 API const struct lysc_node *
 lysc_node_is_disabled(const struct lysc_node *node, int recursive)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     LY_CHECK_ARG_RET(NULL, node, NULL);
 
@@ -838,7 +838,7 @@
     struct lysp_import *imp;
     struct lysp_include *inc;
     LY_ERR ret = LY_EINVAL;
-    LY_ARRAY_SIZE_TYPE u, v;
+    LY_ARRAY_COUNT_TYPE u, v;
     struct lys_yang_parser_ctx *yangctx = NULL;
     struct lys_yin_parser_ctx *yinctx = NULL;
     struct lys_parser_ctx *pctx = NULL;
diff --git a/src/tree_schema.h b/src/tree_schema.h
index a22dd2f..5410de4 100644
--- a/src/tree_schema.h
+++ b/src/tree_schema.h
@@ -388,7 +388,7 @@
     struct lysc_ext_instance *compiled;     /**< pointer to the compiled data if any - in case the source format is YIN,
                                                  some of the information (argument) are available only after compilation */
     LYEXT_SUBSTMT insubstmt;                /**< value identifying placement of the extension instance */
-    LY_ARRAY_SIZE_TYPE insubstmt_index;     /**< in case the instance is in a substatement, this identifies
+    LY_ARRAY_COUNT_TYPE insubstmt_index;    /**< in case the instance is in a substatement, this identifies
                                                  the index of that substatement */
     uint8_t yin;                            /** flag for YIN source format, can be set to LYS_YIN */
     LYEXT_PARENT parent_type;               /**< type of the parent structure */
diff --git a/src/tree_schema_compile.c b/src/tree_schema_compile.c
index 14dafbc..4417027 100644
--- a/src/tree_schema_compile.c
+++ b/src/tree_schema_compile.c
@@ -53,9 +53,9 @@
 
 #define COMPILE_ARRAY_GOTO(CTX, ARRAY_P, ARRAY_C, ITER, FUNC, RET, GOTO) \
     if (ARRAY_P) { \
-        LY_ARRAY_CREATE_GOTO((CTX)->ctx, ARRAY_C, LY_ARRAY_SIZE(ARRAY_P), RET, GOTO); \
-        LY_ARRAY_SIZE_TYPE __array_offset = LY_ARRAY_SIZE(ARRAY_C); \
-        for (ITER = 0; ITER < LY_ARRAY_SIZE(ARRAY_P); ++ITER) { \
+        LY_ARRAY_CREATE_GOTO((CTX)->ctx, ARRAY_C, LY_ARRAY_COUNT(ARRAY_P), RET, GOTO); \
+        LY_ARRAY_COUNT_TYPE __array_offset = LY_ARRAY_COUNT(ARRAY_C); \
+        for (ITER = 0; ITER < LY_ARRAY_COUNT(ARRAY_P); ++ITER) { \
             LY_ARRAY_INCREMENT(ARRAY_C); \
             RET = FUNC(CTX, &(ARRAY_P)[ITER], &(ARRAY_C)[ITER + __array_offset]); \
             LY_CHECK_GOTO(RET != LY_SUCCESS, GOTO); \
@@ -64,9 +64,9 @@
 
 #define COMPILE_ARRAY1_GOTO(CTX, ARRAY_P, ARRAY_C, PARENT, ITER, FUNC, USES_STATUS, RET, GOTO) \
     if (ARRAY_P) { \
-        LY_ARRAY_CREATE_GOTO((CTX)->ctx, ARRAY_C, LY_ARRAY_SIZE(ARRAY_P), RET, GOTO); \
-        LY_ARRAY_SIZE_TYPE __array_offset = LY_ARRAY_SIZE(ARRAY_C); \
-        for (ITER = 0; ITER < LY_ARRAY_SIZE(ARRAY_P); ++ITER) { \
+        LY_ARRAY_CREATE_GOTO((CTX)->ctx, ARRAY_C, LY_ARRAY_COUNT(ARRAY_P), RET, GOTO); \
+        LY_ARRAY_COUNT_TYPE __array_offset = LY_ARRAY_COUNT(ARRAY_C); \
+        for (ITER = 0; ITER < LY_ARRAY_COUNT(ARRAY_P); ++ITER) { \
             LY_ARRAY_INCREMENT(ARRAY_C); \
             RET = FUNC(CTX, &(ARRAY_P)[ITER], PARENT, &(ARRAY_C)[ITER + __array_offset], USES_STATUS); \
             LY_CHECK_GOTO(RET != LY_SUCCESS, GOTO); \
@@ -75,8 +75,8 @@
 
 #define COMPILE_EXTS_GOTO(CTX, EXTS_P, EXT_C, PARENT, PARENT_TYPE, RET, GOTO) \
     if (EXTS_P) { \
-        LY_ARRAY_CREATE_GOTO((CTX)->ctx, EXT_C, LY_ARRAY_SIZE(EXTS_P), RET, GOTO); \
-        for (LY_ARRAY_SIZE_TYPE __exts_iter = 0, __array_offset = LY_ARRAY_SIZE(EXT_C); __exts_iter < LY_ARRAY_SIZE(EXTS_P); ++__exts_iter) { \
+        LY_ARRAY_CREATE_GOTO((CTX)->ctx, EXT_C, LY_ARRAY_COUNT(EXTS_P), RET, GOTO); \
+        for (LY_ARRAY_COUNT_TYPE __exts_iter = 0, __array_offset = LY_ARRAY_COUNT(EXT_C); __exts_iter < LY_ARRAY_COUNT(EXTS_P); ++__exts_iter) { \
             LY_ARRAY_INCREMENT(EXT_C); \
             RET = lys_compile_ext(CTX, &(EXTS_P)[__exts_iter], &(EXT_C)[__exts_iter + __array_offset], PARENT, PARENT_TYPE, NULL); \
             LY_CHECK_GOTO(RET != LY_SUCCESS, GOTO); \
@@ -85,9 +85,9 @@
 
 #define COMPILE_ARRAY_UNIQUE_GOTO(CTX, ARRAY_P, ARRAY_C, ITER, FUNC, RET, GOTO) \
     if (ARRAY_P) { \
-        LY_ARRAY_CREATE_GOTO((CTX)->ctx, ARRAY_C, LY_ARRAY_SIZE(ARRAY_P), RET, GOTO); \
-        LY_ARRAY_SIZE_TYPE __array_offset = LY_ARRAY_SIZE(ARRAY_C); \
-        for (ITER = 0; ITER < LY_ARRAY_SIZE(ARRAY_P); ++ITER) { \
+        LY_ARRAY_CREATE_GOTO((CTX)->ctx, ARRAY_C, LY_ARRAY_COUNT(ARRAY_P), RET, GOTO); \
+        LY_ARRAY_COUNT_TYPE __array_offset = LY_ARRAY_COUNT(ARRAY_C); \
+        for (ITER = 0; ITER < LY_ARRAY_COUNT(ARRAY_P); ++ITER) { \
             LY_ARRAY_INCREMENT(ARRAY_C); \
             RET = FUNC(CTX, &(ARRAY_P)[ITER], ARRAY_C, &(ARRAY_C)[ITER + __array_offset]); \
             LY_CHECK_GOTO(RET != LY_SUCCESS, GOTO); \
@@ -105,7 +105,7 @@
 #define COMPILE_MEMBER_ARRAY_GOTO(CTX, MEMBER_P, ARRAY_C, FUNC, RET, GOTO) \
     if (MEMBER_P) { \
         LY_ARRAY_CREATE_GOTO((CTX)->ctx, ARRAY_C, 1, RET, GOTO); \
-        LY_ARRAY_SIZE_TYPE __array_offset = LY_ARRAY_SIZE(ARRAY_C); \
+        LY_ARRAY_COUNT_TYPE __array_offset = LY_ARRAY_COUNT(ARRAY_C); \
         LY_ARRAY_INCREMENT(ARRAY_C); \
         RET = FUNC(CTX, MEMBER_P, &(ARRAY_C)[__array_offset]); \
         LY_CHECK_GOTO(RET != LY_SUCCESS, GOTO); \
@@ -113,7 +113,7 @@
 
 #define COMPILE_CHECK_UNIQUENESS_ARRAY(CTX, ARRAY, MEMBER, EXCL, STMT, IDENT) \
     if (ARRAY) { \
-        for (LY_ARRAY_SIZE_TYPE u__ = 0; u__ < LY_ARRAY_SIZE(ARRAY); ++u__) { \
+        for (LY_ARRAY_COUNT_TYPE u__ = 0; u__ < LY_ARRAY_COUNT(ARRAY); ++u__) { \
             if (&(ARRAY)[u__] != EXCL && (void*)((ARRAY)[u__].MEMBER) == (void*)(IDENT)) { \
                 LOGVAL((CTX)->ctx, LY_VLOG_STR, (CTX)->path, LY_VCODE_DUPIDENT, IDENT, STMT); \
                 return LY_EVALID; \
@@ -123,7 +123,7 @@
 
 #define COMPILE_CHECK_UNIQUENESS_PARRAY(CTX, ARRAY, MEMBER, EXCL, STMT, IDENT) \
     if (ARRAY) { \
-        for (LY_ARRAY_SIZE_TYPE u__ = 0; u__ < LY_ARRAY_SIZE(ARRAY); ++u__) { \
+        for (LY_ARRAY_COUNT_TYPE u__ = 0; u__ < LY_ARRAY_COUNT(ARRAY); ++u__) { \
             if (&(ARRAY)[u__] != EXCL && (void*)((ARRAY)[u__]->MEMBER) == (void*)(IDENT)) { \
                 LOGVAL((CTX)->ctx, LY_VLOG_STR, (CTX)->path, LY_VCODE_DUPIDENT, IDENT, STMT); \
                 return LY_EVALID; \
@@ -278,11 +278,11 @@
 lysc_patterns_dup(struct ly_ctx *ctx, struct lysc_pattern **orig)
 {
     struct lysc_pattern **dup = NULL;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     assert(orig);
 
-    LY_ARRAY_CREATE_RET(ctx, dup, LY_ARRAY_SIZE(orig), NULL);
+    LY_ARRAY_CREATE_RET(ctx, dup, LY_ARRAY_COUNT(orig), NULL);
     LY_ARRAY_FOR(orig, u) {
         dup[u] = lysc_pattern_dup(orig[u]);
         LY_ARRAY_INCREMENT(dup);
@@ -309,9 +309,9 @@
     dup = calloc(1, sizeof *dup);
     LY_CHECK_ERR_RET(!dup, LOGMEM(ctx), NULL);
     if (orig->parts) {
-        LY_ARRAY_CREATE_GOTO(ctx, dup->parts, LY_ARRAY_SIZE(orig->parts), ret, cleanup);
-        LY_ARRAY_SIZE(dup->parts) = LY_ARRAY_SIZE(orig->parts);
-        memcpy(dup->parts, orig->parts, LY_ARRAY_SIZE(dup->parts) * sizeof *dup->parts);
+        LY_ARRAY_CREATE_GOTO(ctx, dup->parts, LY_ARRAY_COUNT(orig->parts), ret, cleanup);
+        LY_ARRAY_COUNT(dup->parts) = LY_ARRAY_COUNT(orig->parts);
+        memcpy(dup->parts, orig->parts, LY_ARRAY_COUNT(dup->parts) * sizeof *dup->parts);
     }
     DUP_STRING(ctx, orig->eapptag, dup->eapptag);
     DUP_STRING(ctx, orig->emsg, dup->emsg);
@@ -421,7 +421,7 @@
 lys_feature_find(struct lys_module *mod, const char *name, size_t len)
 {
     size_t i;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     struct lysc_feature *f, *flist;
 
     for (i = 0; i < len; ++i) {
@@ -502,7 +502,7 @@
     LY_ERR ret = LY_EVALID;
     const char *name;
     size_t u;
-    LY_ARRAY_SIZE_TYPE v;
+    LY_ARRAY_COUNT_TYPE v;
     const char *prefixed_name = NULL;
 
     DUP_STRING(ctx->ctx, ext_p->argument, ext->argument);
@@ -952,7 +952,7 @@
 lys_identity_precompile(struct lysc_ctx *ctx_sc, struct ly_ctx *ctx, struct lys_module *module,
                         struct lysp_ident *identities_p, struct lysc_ident **identities)
 {
-    LY_ARRAY_SIZE_TYPE offset = 0, u, v;
+    LY_ARRAY_COUNT_TYPE offset = 0, u, v;
     struct lysc_ctx context = {0};
     LY_ERR ret = LY_SUCCESS;
 
@@ -970,11 +970,11 @@
         return LY_SUCCESS;
     }
     if (*identities) {
-        offset = LY_ARRAY_SIZE(*identities);
+        offset = LY_ARRAY_COUNT(*identities);
     }
 
     lysc_update_path(ctx_sc, NULL, "{identity}");
-    LY_ARRAY_CREATE_RET(ctx_sc->ctx, *identities, LY_ARRAY_SIZE(identities_p), LY_EMEM);
+    LY_ARRAY_CREATE_RET(ctx_sc->ctx, *identities, LY_ARRAY_COUNT(identities_p), LY_EMEM);
     LY_ARRAY_FOR(identities_p, u) {
         lysc_update_path(ctx_sc, NULL, identities_p[u].name);
 
@@ -1013,7 +1013,7 @@
 lys_compile_identity_circular_check(struct lysc_ctx *ctx, struct lysc_ident *ident, struct lysc_ident **derived)
 {
     LY_ERR ret = LY_EVALID;
-    LY_ARRAY_SIZE_TYPE u, v;
+    LY_ARRAY_COUNT_TYPE u, v;
     struct ly_set recursion = {0};
     struct lysc_ident *drv;
 
@@ -1021,7 +1021,7 @@
         return LY_SUCCESS;
     }
 
-    for (u = 0; u < LY_ARRAY_SIZE(derived); ++u) {
+    for (u = 0; u < LY_ARRAY_COUNT(derived); ++u) {
         if (ident == derived[u]) {
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
                    "Identity \"%s\" is indirectly derived from itself.", ident->name);
@@ -1035,7 +1035,7 @@
         if (!drv->derived) {
             continue;
         }
-        for (u = 0; u < LY_ARRAY_SIZE(drv->derived); ++u) {
+        for (u = 0; u < LY_ARRAY_COUNT(drv->derived); ++u) {
             if (ident == drv->derived[u]) {
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
                        "Identity \"%s\" is indirectly derived from itself.", ident->name);
@@ -1068,14 +1068,14 @@
 lys_compile_identity_bases(struct lysc_ctx *ctx, struct lys_module *context_module, const char **bases_p,
                            struct lysc_ident *ident, struct lysc_ident ***bases)
 {
-    LY_ARRAY_SIZE_TYPE u, v;
+    LY_ARRAY_COUNT_TYPE u, v;
     const char *s, *name;
     struct lys_module *mod;
     struct lysc_ident **idref, *identities;
 
     assert(ident || bases);
 
-    if (LY_ARRAY_SIZE(bases_p) > 1 && ctx->mod_def->version < 2) {
+    if (LY_ARRAY_COUNT(bases_p) > 1 && ctx->mod_def->version < 2) {
         LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
                "Multiple bases in %s are allowed only in YANG 1.1 modules.", ident ? "identity" : "identityref type");
         return LY_EVALID;
@@ -1152,10 +1152,10 @@
 static LY_ERR
 lys_compile_identities_derived(struct lysc_ctx *ctx, struct lysp_ident *idents_p, struct lysc_ident *idents)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     lysc_update_path(ctx, NULL, "{identity}");
-    for (u = 0; u < LY_ARRAY_SIZE(idents_p); ++u) {
+    for (u = 0; u < LY_ARRAY_COUNT(idents_p); ++u) {
         if (!idents_p[u].bases) {
             continue;
         }
@@ -1171,7 +1171,7 @@
 lys_feature_precompile(struct lysc_ctx *ctx_sc, struct ly_ctx *ctx, struct lys_module *module,
                        struct lysp_feature *features_p, struct lysc_feature **features)
 {
-    LY_ARRAY_SIZE_TYPE offset = 0, u;
+    LY_ARRAY_COUNT_TYPE offset = 0, u;
     struct lysc_ctx context = {0};
 
     assert(ctx_sc || ctx);
@@ -1188,11 +1188,11 @@
         return LY_SUCCESS;
     }
     if (*features) {
-        offset = LY_ARRAY_SIZE(*features);
+        offset = LY_ARRAY_COUNT(*features);
     }
 
     lysc_update_path(ctx_sc, NULL, "{feature}");
-    LY_ARRAY_CREATE_RET(ctx_sc->ctx, *features, LY_ARRAY_SIZE(features_p), LY_EMEM);
+    LY_ARRAY_CREATE_RET(ctx_sc->ctx, *features, LY_ARRAY_COUNT(features_p), LY_EMEM);
     LY_ARRAY_FOR(features_p, u) {
         lysc_update_path(ctx_sc, NULL, features_p[u].name);
 
@@ -1227,7 +1227,7 @@
 lys_compile_feature_circular_check(struct lysc_ctx *ctx, struct lysc_feature *feature, struct lysc_feature **depfeatures)
 {
     LY_ERR ret = LY_EVALID;
-    LY_ARRAY_SIZE_TYPE u, v;
+    LY_ARRAY_COUNT_TYPE u, v;
     struct ly_set recursion = {0};
     struct lysc_feature *drv;
 
@@ -1235,7 +1235,7 @@
         return LY_SUCCESS;
     }
 
-    for (u = 0; u < LY_ARRAY_SIZE(depfeatures); ++u) {
+    for (u = 0; u < LY_ARRAY_COUNT(depfeatures); ++u) {
         if (feature == depfeatures[u]) {
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
                    "Feature \"%s\" is indirectly referenced from itself.", feature->name);
@@ -1249,7 +1249,7 @@
         if (!drv->depfeatures) {
             continue;
         }
-        for (u = 0; u < LY_ARRAY_SIZE(drv->depfeatures); ++u) {
+        for (u = 0; u < LY_ARRAY_COUNT(drv->depfeatures); ++u) {
             if (feature == drv->depfeatures[u]) {
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
                        "Feature \"%s\" is indirectly referenced from itself.", feature->name);
@@ -1278,7 +1278,7 @@
 static LY_ERR
 lys_feature_precompile_finish(struct lysc_ctx *ctx, struct lysp_feature *feature_p, struct lysc_feature *features)
 {
-    LY_ARRAY_SIZE_TYPE u, v, x;
+    LY_ARRAY_COUNT_TYPE u, v, x;
     struct lysc_feature *feature, **df;
     LY_ERR ret = LY_SUCCESS;
 
@@ -1296,9 +1296,9 @@
         COMPILE_EXTS_GOTO(ctx, feature_p->exts, feature->exts, feature, LYEXT_PAR_FEATURE, ret, done);
         COMPILE_ARRAY_GOTO(ctx, feature_p->iffeatures, feature->iffeatures, u, lys_compile_iffeature, ret, done);
         if (feature->iffeatures) {
-            for (u = 0; u < LY_ARRAY_SIZE(feature->iffeatures); ++u) {
+            for (u = 0; u < LY_ARRAY_COUNT(feature->iffeatures); ++u) {
                 if (feature->iffeatures[u].features) {
-                    for (v = 0; v < LY_ARRAY_SIZE(feature->iffeatures[u].features); ++v) {
+                    for (v = 0; v < LY_ARRAY_COUNT(feature->iffeatures[u].features); ++v) {
                         /* check for circular dependency - direct reference first,... */
                         if (feature == feature->iffeatures[u].features[v]) {
                             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
@@ -1338,7 +1338,7 @@
 static void
 lys_feature_precompile_revert(struct lysc_ctx *ctx, struct lys_module *mod)
 {
-    LY_ARRAY_SIZE_TYPE u, v;
+    LY_ARRAY_COUNT_TYPE u, v;
 
     /* keep the dis_features list until the complete lys_module is freed */
     mod->dis_features = mod->compiled->features;
@@ -1494,7 +1494,7 @@
     }
     if (!valcopy && base_range) {
         if (max) {
-            part->max_64 = base_range->parts[LY_ARRAY_SIZE(base_range->parts) - 1].max_64;
+            part->max_64 = base_range->parts[LY_ARRAY_COUNT(base_range->parts) - 1].max_64;
         } else {
             part->min_64 = base_range->parts[0].min_64;
         }
@@ -1651,7 +1651,7 @@
     const char *expr;
     struct lysc_range_part *parts = NULL, *part;
     int range_expected = 0, uns;
-    LY_ARRAY_SIZE_TYPE parts_done = 0, u, v;
+    LY_ARRAY_COUNT_TYPE parts_done = 0, u, v;
 
     assert(range);
     assert(range_p);
@@ -1666,7 +1666,7 @@
                        "Invalid %s restriction - unexpected end of the expression after \"..\" (%s).",
                        length_restr ? "length" : "range", range_p->arg);
                 goto cleanup;
-            } else if (!parts || parts_done == LY_ARRAY_SIZE(parts)) {
+            } else if (!parts || parts_done == LY_ARRAY_COUNT(parts)) {
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
                        "Invalid %s restriction - unexpected end of the expression (%s).",
                        length_restr ? "length" : "range", range_p->arg);
@@ -1701,7 +1701,7 @@
             while (isspace(*expr)) {
                 expr++;
             }
-            if (!parts || LY_ARRAY_SIZE(parts) == parts_done) {
+            if (!parts || LY_ARRAY_COUNT(parts) == parts_done) {
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
                        "Invalid %s restriction - unexpected \"..\" without a lower bound.", length_restr ? "length" : "range");
                 goto cleanup;
@@ -1711,12 +1711,12 @@
         } else if (isdigit(*expr) || (*expr == '-') || (*expr == '+')) {
             /* number */
             if (range_expected) {
-                part = &parts[LY_ARRAY_SIZE(parts) - 1];
+                part = &parts[LY_ARRAY_COUNT(parts) - 1];
                 LY_CHECK_GOTO(range_part_minmax(ctx, part, 1, part->min_64, basetype, 0, length_restr, frdigits, NULL, &expr), cleanup);
                 range_expected = 0;
             } else {
                 LY_ARRAY_NEW_GOTO(ctx->ctx, parts, part, ret, cleanup);
-                LY_CHECK_GOTO(range_part_minmax(ctx, part, 0, parts_done ? parts[LY_ARRAY_SIZE(parts) - 2].max_64 : 0,
+                LY_CHECK_GOTO(range_part_minmax(ctx, part, 0, parts_done ? parts[LY_ARRAY_COUNT(parts) - 2].max_64 : 0,
                                                 basetype, parts_done ? 0 : 1, length_restr, frdigits, NULL, &expr), cleanup);
                 part->max_64 = part->min_64;
             }
@@ -1733,12 +1733,12 @@
                 goto cleanup;
             }
             if (range_expected) {
-                part = &parts[LY_ARRAY_SIZE(parts) - 1];
+                part = &parts[LY_ARRAY_COUNT(parts) - 1];
                 LY_CHECK_GOTO(range_part_minmax(ctx, part, 1, part->min_64, basetype, 0, length_restr, frdigits, base_range, NULL), cleanup);
                 range_expected = 0;
             } else {
                 LY_ARRAY_NEW_GOTO(ctx->ctx, parts, part, ret, cleanup);
-                LY_CHECK_GOTO(range_part_minmax(ctx, part, 1, parts_done ? parts[LY_ARRAY_SIZE(parts) - 2].max_64 : 0,
+                LY_CHECK_GOTO(range_part_minmax(ctx, part, 1, parts_done ? parts[LY_ARRAY_COUNT(parts) - 2].max_64 : 0,
                                                 basetype, parts_done ? 0 : 1, length_restr, frdigits, base_range, NULL), cleanup);
                 part->min_64 = part->max_64;
             }
@@ -1772,7 +1772,7 @@
             ret = LY_EINT;
             goto cleanup;
         }
-        for (u = v = 0; u < parts_done && v < LY_ARRAY_SIZE(base_range->parts); ++u) {
+        for (u = v = 0; u < parts_done && v < LY_ARRAY_COUNT(base_range->parts); ++u) {
             if ((uns && parts[u].min_u64 < base_range->parts[v].min_u64) || (!uns && parts[u].min_64 < base_range->parts[v].min_64)) {
                 goto baseerror;
             }
@@ -2119,7 +2119,7 @@
                           struct lysc_pattern **base_patterns, struct lysc_pattern ***patterns)
 {
     struct lysc_pattern **pattern;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     LY_ERR ret = LY_SUCCESS;
 
     /* first, copy the patterns from the base type */
@@ -2198,7 +2198,7 @@
                        struct lysc_type_bitenum_item *base_enums, struct lysc_type_bitenum_item **enums)
 {
     LY_ERR ret = LY_SUCCESS;
-    LY_ARRAY_SIZE_TYPE u, v, match = 0;
+    LY_ARRAY_COUNT_TYPE u, v, match = 0;
     int32_t value = 0;
     uint32_t position = 0;
     struct lysc_type_bitenum_item *e, storage;
@@ -2222,7 +2222,7 @@
                     break;
                 }
             }
-            if (v == LY_ARRAY_SIZE(base_enums)) {
+            if (v == LY_ARRAY_COUNT(base_enums)) {
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
                        "Invalid %s - derived type adds new item \"%s\".",
                        basetype == LY_TYPE_ENUM ? "enumeration" : "bits", e->name);
@@ -2239,7 +2239,7 @@
                     value = e->value + 1;
                 }
                 /* check collision with other values */
-                for (v = 0; v < LY_ARRAY_SIZE(*enums) - 1; ++v) {
+                for (v = 0; v < LY_ARRAY_COUNT(*enums) - 1; ++v) {
                     if (e->value == (*enums)[v].value) {
                         LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
                                "Invalid enumeration - value %d collide in items \"%s\" and \"%s\".",
@@ -2271,7 +2271,7 @@
                     position = (uint32_t)e->value + 1;
                 }
                 /* check collision with other values */
-                for (v = 0; v < LY_ARRAY_SIZE(*enums) - 1; ++v) {
+                for (v = 0; v < LY_ARRAY_COUNT(*enums) - 1; ++v) {
                     if (e->value == (*enums)[v].value) {
                         LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
                                "Invalid bits - position %u collide in items \"%s\" and \"%s\".",
@@ -2424,7 +2424,7 @@
 {
     LY_ERR ret = LY_EVALID;
     const struct lysc_node *iter;
-    LY_ARRAY_SIZE_TYPE u, v, count;
+    LY_ARRAY_COUNT_TYPE u, v, count;
     struct ly_set features = {0};
 
     for (iter = refnode; iter; iter = iter->parent) {
@@ -2781,18 +2781,18 @@
                 return LY_EVALID;
             }
             /* compile the type */
-            LY_ARRAY_CREATE_RET(ctx->ctx, un->types, LY_ARRAY_SIZE(type_p->types), LY_EVALID);
-            for (LY_ARRAY_SIZE_TYPE u = 0, additional = 0; u < LY_ARRAY_SIZE(type_p->types); ++u) {
+            LY_ARRAY_CREATE_RET(ctx->ctx, un->types, LY_ARRAY_COUNT(type_p->types), LY_EVALID);
+            for (LY_ARRAY_COUNT_TYPE u = 0, additional = 0; u < LY_ARRAY_COUNT(type_p->types); ++u) {
                 LY_CHECK_RET(lys_compile_type(ctx, context_node_p, context_flags, context_mod, context_name,
                                               &type_p->types[u], &un->types[u + additional], NULL));
                 if (un->types[u + additional]->basetype == LY_TYPE_UNION) {
                     /* add space for additional types from the union subtype */
                     un_aux = (struct lysc_type_union *)un->types[u + additional];
-                    LY_ARRAY_RESIZE_ERR_RET(ctx->ctx, un->types, (*((uint64_t*)(type_p->types) - 1)) + additional + LY_ARRAY_SIZE(un_aux->types) - 1,
+                    LY_ARRAY_RESIZE_ERR_RET(ctx->ctx, un->types, (*((uint64_t*)(type_p->types) - 1)) + additional + LY_ARRAY_COUNT(un_aux->types) - 1,
                                             lysc_type_free(ctx->ctx, (struct lysc_type*)un_aux), LY_EMEM);
 
                     /* copy subtypes of the subtype union */
-                    for (LY_ARRAY_SIZE_TYPE v = 0; v < LY_ARRAY_SIZE(un_aux->types); ++v) {
+                    for (LY_ARRAY_COUNT_TYPE v = 0; v < LY_ARRAY_COUNT(un_aux->types); ++v) {
                         if (un_aux->types[v]->basetype == LY_TYPE_LEAFREF) {
                             /* duplicate the whole structure because of the instance-specific path resolving for realtype */
                             un->types[u + additional] = calloc(1, sizeof(struct lysc_type_leafref));
@@ -3179,7 +3179,7 @@
                           const struct lysc_notif *notifs, const char *name, void *exclude)
 {
     const struct lysc_node *iter;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     LY_LIST_FOR(children, iter) {
         if (iter != exclude && iter->module == ctx->mod && !strcmp(name, iter->name)) {
@@ -3434,7 +3434,7 @@
         /* store to validate the path in the current context at the end of schema compiling when all the nodes are present */
         ly_set_add(&ctx->leafrefs, leaf, 0);
     } else if (leaf->type->basetype == LY_TYPE_UNION) {
-        LY_ARRAY_SIZE_TYPE u;
+        LY_ARRAY_COUNT_TYPE u;
         LY_ARRAY_FOR(((struct lysc_type_union*)leaf->type)->types, u) {
             if (((struct lysc_type_union*)leaf->type)->types[u]->basetype == LY_TYPE_LEAFREF) {
                 /* store to validate the path in the current context at the end of schema compiling when all the nodes are present */
@@ -3530,7 +3530,7 @@
 {
     struct lysp_node_leaflist *llist_p = (struct lysp_node_leaflist*)node_p;
     struct lysc_node_leaflist *llist = (struct lysc_node_leaflist*)node;
-    LY_ARRAY_SIZE_TYPE u, v;
+    LY_ARRAY_COUNT_TYPE u, v;
     LY_ERR ret = LY_SUCCESS;
 
     COMPILE_ARRAY_GOTO(ctx, llist_p->musts, llist->musts, u, lys_compile_must, ret, done);
@@ -3556,8 +3556,8 @@
 
     if (llist_p->dflts) {
         llist->dflts = NULL; /* reset the temporary llist_p->dflts */
-        LY_ARRAY_CREATE_GOTO(ctx->ctx, llist->dflts_mods, LY_ARRAY_SIZE(llist_p->dflts), ret, done);
-        LY_ARRAY_CREATE_GOTO(ctx->ctx, llist->dflts, LY_ARRAY_SIZE(llist_p->dflts), ret, done);
+        LY_ARRAY_CREATE_GOTO(ctx->ctx, llist->dflts_mods, LY_ARRAY_COUNT(llist_p->dflts), ret, done);
+        LY_ARRAY_CREATE_GOTO(ctx->ctx, llist->dflts, LY_ARRAY_COUNT(llist_p->dflts), ret, done);
         LY_ARRAY_FOR(llist_p->dflts, u) {
             struct ly_err_item *err = NULL;
             LY_ARRAY_INCREMENT(llist->dflts_mods);
@@ -3586,10 +3586,10 @@
         }
         llist->flags |= LYS_SET_DFLT;
     }
-    if ((llist->flags & LYS_CONFIG_W) && llist->dflts && LY_ARRAY_SIZE(llist->dflts)) {
+    if ((llist->flags & LYS_CONFIG_W) && llist->dflts && LY_ARRAY_COUNT(llist->dflts)) {
         /* configuration data values must be unique - so check the default values */
         LY_ARRAY_FOR(llist->dflts, u) {
-            for (v = u + 1; v < LY_ARRAY_SIZE(llist->dflts); ++v) {
+            for (v = u + 1; v < LY_ARRAY_COUNT(llist->dflts); ++v) {
                 if (!llist->type->plugin->compare(llist->dflts[u], llist->dflts[v])) {
                     int dynamic = 0;
                     const char *val = llist->type->plugin->print(llist->dflts[v], LYD_XML, lys_get_prefix, llist->dflts_mods[v], &dynamic);
@@ -3632,11 +3632,11 @@
     struct lysc_node *parent;
     const char *keystr, *delim;
     size_t len;
-    LY_ARRAY_SIZE_TYPE v;
+    LY_ARRAY_COUNT_TYPE v;
     int config;
     uint16_t flags;
 
-    for (v = 0; v < LY_ARRAY_SIZE(uniques); ++v) {
+    for (v = 0; v < LY_ARRAY_COUNT(uniques); ++v) {
         config = -1;
         LY_ARRAY_NEW_RET(ctx->ctx, list->uniques, unique, LY_EMEM);
         keystr = uniques[v];
@@ -4286,7 +4286,7 @@
 static void
 lys_compile_augment_sort_(struct lysp_augment *aug_p, struct lysp_augment **result)
 {
-    LY_ARRAY_SIZE_TYPE v;
+    LY_ARRAY_COUNT_TYPE v;
     size_t len;
 
     len = strlen(aug_p->nodeid);
@@ -4294,9 +4294,9 @@
         if (strlen(result[v]->nodeid) <= len) {
             continue;
         }
-        if (v < LY_ARRAY_SIZE(result)) {
+        if (v < LY_ARRAY_COUNT(result)) {
             /* move the rest of array */
-            memmove(&result[v + 1], &result[v], (LY_ARRAY_SIZE(result) - v) * sizeof *result);
+            memmove(&result[v + 1], &result[v], (LY_ARRAY_COUNT(result) - v) * sizeof *result);
             break;
         }
     }
@@ -4321,17 +4321,17 @@
 lys_compile_augment_sort(struct lysc_ctx *ctx, struct lysp_augment *aug_p, struct lysp_include *inc_p, struct lysp_augment ***augments)
 {
     struct lysp_augment **result = NULL;
-    LY_ARRAY_SIZE_TYPE u, v, count = 0;
+    LY_ARRAY_COUNT_TYPE u, v, count = 0;
 
     assert(augments);
 
     /* get count of the augments in module and all its submodules */
     if (aug_p) {
-        count += LY_ARRAY_SIZE(aug_p);
+        count += LY_ARRAY_COUNT(aug_p);
     }
     LY_ARRAY_FOR(inc_p, u) {
         if (inc_p[u].submodule->augments) {
-            count += LY_ARRAY_SIZE(inc_p[u].submodule->augments);
+            count += LY_ARRAY_COUNT(inc_p[u].submodule->augments);
         }
     }
 
@@ -4626,7 +4626,7 @@
          .prev = (struct lysc_node*)&context_node_fake,
          .actions = NULL, .notifs = NULL};
     struct lysp_grp *grp = NULL;
-    LY_ARRAY_SIZE_TYPE u, v;
+    LY_ARRAY_COUNT_TYPE u, v;
     uint32_t grp_stack_count;
     int found;
     const char *id, *name, *prefix;
@@ -4639,7 +4639,7 @@
     struct ly_set refined = {0};
     struct lysc_when **when, *when_shared;
     struct lysp_augment **augments = NULL;
-    LY_ARRAY_SIZE_TYPE actions_index = 0, notifs_index = 0;
+    LY_ARRAY_COUNT_TYPE actions_index = 0, notifs_index = 0;
     struct lysc_notif **notifs = NULL;
     struct lysc_action **actions = NULL;
 
@@ -4673,7 +4673,7 @@
         /* search in top-level groupings of the main module ... */
         grp = mod->parsed->groupings;
         if (grp) {
-            for (u = 0; !found && u < LY_ARRAY_SIZE(grp); ++u) {
+            for (u = 0; !found && u < LY_ARRAY_COUNT(grp); ++u) {
                 if (!strcmp(grp[u].name, name)) {
                     grp = &grp[u];
                     found = 1;
@@ -4682,10 +4682,10 @@
         }
         if (!found && mod->parsed->includes) {
             /* ... and all the submodules */
-            for (u = 0; !found && u < LY_ARRAY_SIZE(mod->parsed->includes); ++u) {
+            for (u = 0; !found && u < LY_ARRAY_COUNT(mod->parsed->includes); ++u) {
                 grp = mod->parsed->includes[u].submodule->groupings;
                 if (grp) {
-                    for (v = 0; !found && v < LY_ARRAY_SIZE(grp); ++v) {
+                    for (v = 0; !found && v < LY_ARRAY_COUNT(grp); ++v) {
                         if (!strcmp(grp[v].name, name)) {
                             grp = &grp[v];
                             found = 1;
@@ -4777,26 +4777,26 @@
     /* compile actions */
     actions = parent ? lysc_node_actions_p(parent) : &ctx->mod->compiled->rpcs;
     if (actions) {
-        actions_index = *actions ? LY_ARRAY_SIZE(*actions) : 0;
+        actions_index = *actions ? LY_ARRAY_COUNT(*actions) : 0;
         COMPILE_ARRAY1_GOTO(ctx, grp->actions, *actions, parent, u, lys_compile_action, 0, ret, cleanup);
         if (*actions && (uses_p->augments || uses_p->refines)) {
             /* but for augment and refine, we need to separate the compiled grouping's actions to avoid modification of others */
-            LY_ARRAY_CREATE_GOTO(ctx->ctx, context_node_fake.actions, LY_ARRAY_SIZE(*actions) - actions_index, ret, cleanup);
-            LY_ARRAY_SIZE(context_node_fake.actions) = LY_ARRAY_SIZE(*actions) - actions_index;
-            memcpy(context_node_fake.actions, &(*actions)[actions_index], LY_ARRAY_SIZE(context_node_fake.actions) * sizeof **actions);
+            LY_ARRAY_CREATE_GOTO(ctx->ctx, context_node_fake.actions, LY_ARRAY_COUNT(*actions) - actions_index, ret, cleanup);
+            LY_ARRAY_COUNT(context_node_fake.actions) = LY_ARRAY_COUNT(*actions) - actions_index;
+            memcpy(context_node_fake.actions, &(*actions)[actions_index], LY_ARRAY_COUNT(context_node_fake.actions) * sizeof **actions);
         }
     }
 
     /* compile notifications */
     notifs = parent ? lysc_node_notifs_p(parent) : &ctx->mod->compiled->notifs;
     if (notifs) {
-        notifs_index = *notifs ? LY_ARRAY_SIZE(*notifs) : 0;
+        notifs_index = *notifs ? LY_ARRAY_COUNT(*notifs) : 0;
         COMPILE_ARRAY1_GOTO(ctx, grp->notifs, *notifs, parent, u, lys_compile_notif, 0, ret, cleanup);
         if (*notifs && (uses_p->augments || uses_p->refines)) {
             /* but for augment and refine, we need to separate the compiled grouping's notification to avoid modification of others */
-            LY_ARRAY_CREATE_GOTO(ctx->ctx, context_node_fake.notifs, LY_ARRAY_SIZE(*notifs) - notifs_index, ret, cleanup);
-            LY_ARRAY_SIZE(context_node_fake.notifs) = LY_ARRAY_SIZE(*notifs) - notifs_index;
-            memcpy(context_node_fake.notifs, &(*notifs)[notifs_index], LY_ARRAY_SIZE(context_node_fake.notifs) * sizeof **notifs);
+            LY_ARRAY_CREATE_GOTO(ctx->ctx, context_node_fake.notifs, LY_ARRAY_COUNT(*notifs) - notifs_index, ret, cleanup);
+            LY_ARRAY_COUNT(context_node_fake.notifs) = LY_ARRAY_COUNT(*notifs) - notifs_index;
+            memcpy(context_node_fake.notifs, &(*notifs)[notifs_index], LY_ARRAY_COUNT(context_node_fake.notifs) * sizeof **notifs);
         }
     }
 
@@ -4822,10 +4822,10 @@
 
         /* default value */
         if (rfn->dflts) {
-            if ((node->nodetype != LYS_LEAFLIST) && LY_ARRAY_SIZE(rfn->dflts) > 1) {
+            if ((node->nodetype != LYS_LEAFLIST) && LY_ARRAY_COUNT(rfn->dflts) > 1) {
                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
-                       "Invalid refine of default - %s cannot hold %"LY_PRI_ARRAY_SIZE_TYPE" default values.",
-                       lys_nodetype2str(node->nodetype), LY_ARRAY_SIZE(rfn->dflts));
+                       "Invalid refine of default - %s cannot hold %"LY_PRI_ARRAY_COUNT_TYPE" default values.",
+                       lys_nodetype2str(node->nodetype), LY_ARRAY_COUNT(rfn->dflts));
                 goto cleanup;
             }
             if (!(node->nodetype & (LYS_LEAF | LYS_LEAFLIST | LYS_CHOICE))) {
@@ -4890,8 +4890,8 @@
                 llist->dflts_mods = NULL;
 
                 /* create the new set of the default values */
-                LY_ARRAY_CREATE_GOTO(ctx->ctx, llist->dflts_mods, LY_ARRAY_SIZE(rfn->dflts), ret, cleanup);
-                LY_ARRAY_CREATE_GOTO(ctx->ctx, llist->dflts, LY_ARRAY_SIZE(rfn->dflts), ret, cleanup);
+                LY_ARRAY_CREATE_GOTO(ctx->ctx, llist->dflts_mods, LY_ARRAY_COUNT(rfn->dflts), ret, cleanup);
+                LY_ARRAY_CREATE_GOTO(ctx->ctx, llist->dflts, LY_ARRAY_COUNT(rfn->dflts), ret, cleanup);
                 LY_ARRAY_FOR(rfn->dflts, u) {
                     struct ly_err_item *err = NULL;
                     LY_ARRAY_INCREMENT(llist->dflts_mods);
@@ -5091,11 +5091,11 @@
     if (uses_p->augments || uses_p->refines) {
         /* return back actions and notifications in case they were separated for augment/refine processing */
         if (context_node_fake.actions) {
-            memcpy(&(*actions)[actions_index], context_node_fake.actions, LY_ARRAY_SIZE(context_node_fake.actions) * sizeof **actions);
+            memcpy(&(*actions)[actions_index], context_node_fake.actions, LY_ARRAY_COUNT(context_node_fake.actions) * sizeof **actions);
             LY_ARRAY_FREE(context_node_fake.actions);
         }
         if (context_node_fake.notifs) {
-            memcpy(&(*notifs)[notifs_index], context_node_fake.notifs, LY_ARRAY_SIZE(context_node_fake.notifs) * sizeof **notifs);
+            memcpy(&(*notifs)[notifs_index], context_node_fake.notifs, LY_ARRAY_COUNT(context_node_fake.notifs) * sizeof **notifs);
             LY_ARRAY_FREE(context_node_fake.notifs);
         }
     }
@@ -5530,7 +5530,7 @@
     struct lysp_deviate_add *d_add;
     struct lysp_deviate_del *d_del;
     struct lysp_deviate_rpl *d_rpl;
-    LY_ARRAY_SIZE_TYPE u, v, x, y, z;
+    LY_ARRAY_COUNT_TYPE u, v, x, y, z;
     struct lysc_deviation {
         const char *nodeid;
         struct lysc_node *target;      /* target node of the deviation */
@@ -5612,9 +5612,9 @@
     }
 
 #define DEV_CHECK_CARDINALITY(ARRAY, MAX, PROPERTY) \
-    if (LY_ARRAY_SIZE(ARRAY) > MAX) { \
-        LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS, "Invalid deviation of %s with too many (%"LY_PRI_ARRAY_SIZE_TYPE") %s properties.", \
-               lys_nodetype2str(devs[u]->target->nodetype), LY_ARRAY_SIZE(ARRAY), PROPERTY); \
+    if (LY_ARRAY_COUNT(ARRAY) > MAX) { \
+        LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS, "Invalid deviation of %s with too many (%"LY_PRI_ARRAY_COUNT_TYPE") %s properties.", \
+               lys_nodetype2str(devs[u]->target->nodetype), LY_ARRAY_COUNT(ARRAY), PROPERTY); \
         goto cleanup; \
     }
 
@@ -5665,7 +5665,7 @@
         LY_ARRAY_FOR(((TYPE)devs[u]->target)->ARRAY_TRG, y) { \
             if (!strcmp(((TYPE)devs[u]->target)->ARRAY_TRG[y]VALMEMBER_CMP, d_del->ARRAY_DEV[x]VALMEMBER)) { break; } \
         } \
-        if (y == LY_ARRAY_SIZE(((TYPE)devs[u]->target)->ARRAY_TRG)) { \
+        if (y == LY_ARRAY_COUNT(((TYPE)devs[u]->target)->ARRAY_TRG)) { \
             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE, \
                    "Invalid deviation deleting \"%s\" property \"%s\" which does not match any of the target's property values.", \
                    PROPERTY, d_del->ARRAY_DEV[x]VALMEMBER); \
@@ -5675,9 +5675,9 @@
         DELFUNC(ctx->ctx, DELFUNC_DEREF((TYPE)devs[u]->target)->ARRAY_TRG[y]); \
         memmove(&((TYPE)devs[u]->target)->ARRAY_TRG[y], \
                 &((TYPE)devs[u]->target)->ARRAY_TRG[y + 1], \
-                (LY_ARRAY_SIZE(((TYPE)devs[u]->target)->ARRAY_TRG) - y) * (sizeof *((TYPE)devs[u]->target)->ARRAY_TRG)); \
+                (LY_ARRAY_COUNT(((TYPE)devs[u]->target)->ARRAY_TRG) - y) * (sizeof *((TYPE)devs[u]->target)->ARRAY_TRG)); \
     } \
-    if (!LY_ARRAY_SIZE(((TYPE)devs[u]->target)->ARRAY_TRG)) { \
+    if (!LY_ARRAY_COUNT(((TYPE)devs[u]->target)->ARRAY_TRG)) { \
         LY_ARRAY_FREE(((TYPE)devs[u]->target)->ARRAY_TRG); \
         ((TYPE)devs[u]->target)->ARRAY_TRG = NULL; \
     }
@@ -5704,9 +5704,9 @@
 
         /* not-supported */
         if (devs[u]->not_supported) {
-            if (LY_ARRAY_SIZE(devs[u]->deviates) > 1) {
-                LOGWRN(ctx->ctx, "Useless multiple (%"LY_PRI_ARRAY_SIZE_TYPE") deviates on node \"%s\" since the node is not-supported.",
-                       LY_ARRAY_SIZE(devs[u]->deviates), devs[u]->nodeid);
+            if (LY_ARRAY_COUNT(devs[u]->deviates) > 1) {
+                LOGWRN(ctx->ctx, "Useless multiple (%"LY_PRI_ARRAY_COUNT_TYPE") deviates on node \"%s\" since the node is not-supported.",
+                       LY_ARRAY_COUNT(devs[u]->deviates), devs[u]->nodeid);
             }
 
 #define REMOVE_NONDATA(ARRAY, TYPE, GETFUNC, FREEFUNC) \
@@ -5718,9 +5718,9 @@
     LY_ARRAY_FOR(ARRAY, x) { \
         if (&ARRAY[x] == (TYPE*)devs[u]->target) { break; } \
     } \
-    if (x < LY_ARRAY_SIZE(ARRAY)) { \
+    if (x < LY_ARRAY_COUNT(ARRAY)) { \
         FREEFUNC(ctx->ctx, &ARRAY[x]); \
-        memmove(&ARRAY[x], &ARRAY[x + 1], (LY_ARRAY_SIZE(ARRAY) - (x + 1)) * sizeof *ARRAY); \
+        memmove(&ARRAY[x], &ARRAY[x + 1], (LY_ARRAY_COUNT(ARRAY) - (x + 1)) * sizeof *ARRAY); \
         LY_ARRAY_DECREMENT(ARRAY); \
     }
 
@@ -5851,10 +5851,10 @@
                             llist->dflts_mods = NULL;
                         }
                         /* add new default value(s) */
-                        LY_ARRAY_CREATE_GOTO(ctx->ctx, llist->dflts_mods, LY_ARRAY_SIZE(d_add->dflts), ret, cleanup);
-                        LY_ARRAY_CREATE_GOTO(ctx->ctx, llist->dflts, LY_ARRAY_SIZE(d_add->dflts), ret, cleanup);
-                        for (x = y = LY_ARRAY_SIZE(llist->dflts);
-                                x < LY_ARRAY_SIZE(d_add->dflts) + y; ++x) {
+                        LY_ARRAY_CREATE_GOTO(ctx->ctx, llist->dflts_mods, LY_ARRAY_COUNT(d_add->dflts), ret, cleanup);
+                        LY_ARRAY_CREATE_GOTO(ctx->ctx, llist->dflts, LY_ARRAY_COUNT(d_add->dflts), ret, cleanup);
+                        for (x = y = LY_ARRAY_COUNT(llist->dflts);
+                                x < LY_ARRAY_COUNT(d_add->dflts) + y; ++x) {
                             LY_ARRAY_INCREMENT(llist->dflts_mods);
                             llist->dflts_mods[x] = ctx->mod_def;
                             LY_ARRAY_INCREMENT(llist->dflts);
@@ -6042,19 +6042,19 @@
                                 /* complete match - remove the unique */
                                 LY_ARRAY_DECREMENT(list->uniques);
                                 LY_ARRAY_FREE(list->uniques[z]);
-                                memmove(&list->uniques[z], &list->uniques[z + 1], (LY_ARRAY_SIZE(list->uniques) - z) * (sizeof *list->uniques));
+                                memmove(&list->uniques[z], &list->uniques[z + 1], (LY_ARRAY_COUNT(list->uniques) - z) * (sizeof *list->uniques));
                                 --z;
                                 break;
                             }
                         }
-                        if (!list->uniques || z == LY_ARRAY_SIZE(list->uniques)) {
+                        if (!list->uniques || z == LY_ARRAY_COUNT(list->uniques)) {
                             LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
                                    "Invalid deviation deleting \"unique\" property \"%s\" which does not match any of the target's property values.",
                                    d_del->uniques[x]);
                             goto cleanup;
                         }
                     }
-                    if (!LY_ARRAY_SIZE(list->uniques)) {
+                    if (!LY_ARRAY_COUNT(list->uniques)) {
                         LY_ARRAY_FREE(list->uniques);
                         list->uniques = NULL;
                     }
@@ -6112,7 +6112,7 @@
                                 }
                                 dflt = NULL;
                             }
-                            if (y == LY_ARRAY_SIZE(llist->dflts)) {
+                            if (y == LY_ARRAY_COUNT(llist->dflts)) {
                                 LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE, "Invalid deviation deleting \"default\" property \"%s\" "
                                        "which does not match any of the target's property values.", d_del->dflts[x]);
                                 goto cleanup;
@@ -6126,10 +6126,10 @@
                             llist->dflts[y]->realtype->plugin->free(ctx->ctx, llist->dflts[y]);
                             lysc_type_free(ctx->ctx, llist->dflts[y]->realtype);
                             free(llist->dflts[y]);
-                            memmove(&llist->dflts[y], &llist->dflts[y + 1], (LY_ARRAY_SIZE(llist->dflts) - y) * (sizeof *llist->dflts));
-                            memmove(&llist->dflts_mods[y], &llist->dflts_mods[y + 1], (LY_ARRAY_SIZE(llist->dflts_mods) - y) * (sizeof *llist->dflts_mods));
+                            memmove(&llist->dflts[y], &llist->dflts[y + 1], (LY_ARRAY_COUNT(llist->dflts) - y) * (sizeof *llist->dflts));
+                            memmove(&llist->dflts_mods[y], &llist->dflts_mods[y + 1], (LY_ARRAY_COUNT(llist->dflts_mods) - y) * (sizeof *llist->dflts_mods));
                         }
-                        if (!LY_ARRAY_SIZE(llist->dflts)) {
+                        if (!LY_ARRAY_COUNT(llist->dflts)) {
                             LY_ARRAY_FREE(llist->dflts_mods);
                             llist->dflts_mods = NULL;
                             LY_ARRAY_FREE(llist->dflts);
@@ -6671,7 +6671,7 @@
     struct lyxp_set tmp_set;
     struct lyxp_set_scnode *xp_scnode;
     uint32_t i, j;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int idx;
     struct lysc_when *when;
     LY_ERR ret = LY_SUCCESS;
@@ -6760,7 +6760,7 @@
 {
     struct lyxp_set tmp_set;
     uint32_t i;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     int opts, input_done = 0;
     struct lysc_when **when = NULL;
     struct lysc_must *musts = NULL;
@@ -6899,7 +6899,7 @@
                                  lys_resolve_prefix, lref->path_context, LYD_SCHEMA, &p));
 
     /* get the target node */
-    target = p[LY_ARRAY_SIZE(p) - 1].node;
+    target = p[LY_ARRAY_COUNT(p) - 1].node;
     ly_path_free(node->module->ctx, p);
 
     if (!(target->nodetype & (LYS_LEAF | LYS_LEAFLIST))) {
@@ -6994,7 +6994,7 @@
     struct lysc_node *node;
     struct lysc_type *type, *typeiter;
     struct lysc_type_leafref *lref;
-    LY_ARRAY_SIZE_TYPE v;
+    LY_ARRAY_COUNT_TYPE v;
     uint32_t i;
 
     /* for leafref, we need 2 rounds - first detects circular chain by storing the first referred type (which
@@ -7072,7 +7072,7 @@
     struct lysp_augment **augments = NULL;
     struct lysp_grp *grps;
     struct lys_module *m;
-    LY_ARRAY_SIZE_TYPE u, v;
+    LY_ARRAY_COUNT_TYPE u, v;
     uint32_t i;
     LY_ERR ret = LY_SUCCESS;
 
diff --git a/src/tree_schema_free.c b/src/tree_schema_free.c
index c931b4a..7416e6b 100644
--- a/src/tree_schema_free.c
+++ b/src/tree_schema_free.c
@@ -729,7 +729,7 @@
 static void
 lysc_node_leaflist_free(struct ly_ctx *ctx, struct lysc_node_leaflist *node)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     FREE_ARRAY(ctx, node->musts, lysc_must_free);
     if (node->type) {
@@ -748,7 +748,7 @@
 static void
 lysc_node_list_free(struct ly_ctx *ctx, struct lysc_node_list *node)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     struct lysc_node *child, *child_next;
 
     LY_LIST_FOR_SAFE(node->child, child_next, child) {
diff --git a/src/tree_schema_helpers.c b/src/tree_schema_helpers.c
index b399594..cd501d8 100644
--- a/src/tree_schema_helpers.c
+++ b/src/tree_schema_helpers.c
@@ -246,7 +246,7 @@
     uint8_t i, r;
     struct lysp_revision rev;
 
-    for (i = 1, r = 0; revs && i < LY_ARRAY_SIZE(revs); i++) {
+    for (i = 1, r = 0; revs && i < LY_ARRAY_COUNT(revs); i++) {
         if (strcmp(revs[i].date, revs[r].date) > 0) {
             r = i;
         }
@@ -264,7 +264,7 @@
 lysp_type_match(const char *name, struct lysp_node *node)
 {
     const struct lysp_tpdf *typedefs;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     typedefs = lysp_node_typedefs(node);
     LY_ARRAY_FOR(typedefs, u) {
@@ -357,7 +357,7 @@
 {
     const char *str, *name;
     struct lysp_tpdf *typedefs;
-    LY_ARRAY_SIZE_TYPE u, v;
+    LY_ARRAY_COUNT_TYPE u, v;
 
     assert(id);
     assert(start_module);
@@ -466,7 +466,7 @@
     uint32_t hash;
     size_t name_len;
     const char *name;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     const struct lysp_tpdf *typedefs;
 
     assert(ctx);
@@ -532,7 +532,7 @@
 lysp_parse_finalize_reallocated(struct lys_parser_ctx *ctx, struct lysp_grp *groupings, struct lysp_augment *augments,
                                 struct lysp_action *actions, struct lysp_notif *notifs)
 {
-    LY_ARRAY_SIZE_TYPE u, v;
+    LY_ARRAY_COUNT_TYPE u, v;
     struct lysp_node *child;
 
     /* finalize parent pointers to the reallocated items */
@@ -625,7 +625,7 @@
     struct hash_table *ids_global;
     struct hash_table *ids_scoped;
     const struct lysp_tpdf *typedefs;
-    LY_ARRAY_SIZE_TYPE u, v;
+    LY_ARRAY_COUNT_TYPE u, v;
     uint32_t i;
     LY_ERR ret = LY_EVALID;
 
@@ -1057,7 +1057,7 @@
 const char *
 lys_prefix_find_module(const struct lys_module *mod, const struct lys_module *import)
 {
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     if (import == mod) {
         return mod->prefix;
@@ -1630,18 +1630,18 @@
     return result;
 }
 
-LY_ARRAY_SIZE_TYPE
-lysp_ext_instance_iter(struct lysp_ext_instance *ext, LY_ARRAY_SIZE_TYPE index, LYEXT_SUBSTMT substmt)
+LY_ARRAY_COUNT_TYPE
+lysp_ext_instance_iter(struct lysp_ext_instance *ext, LY_ARRAY_COUNT_TYPE index, LYEXT_SUBSTMT substmt)
 {
     LY_CHECK_ARG_RET(NULL, ext, LY_EINVAL);
 
-    for (; index < LY_ARRAY_SIZE(ext); index++) {
+    for (; index < LY_ARRAY_COUNT(ext); index++) {
         if (ext[index].insubstmt == substmt) {
             return index;
         }
     }
 
-    return LY_ARRAY_SIZE(ext);
+    return LY_ARRAY_COUNT(ext);
 }
 
 /**
@@ -1656,7 +1656,7 @@
 lys_get_prefix(const struct lys_module *mod, void *private)
 {
     struct lys_module *context_mod = (struct lys_module*)private;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     if (context_mod == mod) {
         return context_mod->prefix;
diff --git a/src/tree_schema_internal.h b/src/tree_schema_internal.h
index 6dba9f2..0f5b3f6 100644
--- a/src/tree_schema_internal.h
+++ b/src/tree_schema_internal.h
@@ -63,7 +63,7 @@
  */
 #define CHECK_UNIQUENESS(CTX, ARRAY, MEMBER, STMT, IDENT) \
     if (ARRAY) { \
-        for (LY_ARRAY_SIZE_TYPE u_ = 0; u_ < LY_ARRAY_SIZE(ARRAY) - 1; ++u_) { \
+        for (LY_ARRAY_COUNT_TYPE u_ = 0; u_ < LY_ARRAY_COUNT(ARRAY) - 1; ++u_) { \
             if (!strcmp((ARRAY)[u_].MEMBER, IDENT)) { \
                 LOGVAL_PARSER(CTX, LY_VCODE_DUPIDENT, IDENT, STMT); \
                 return LY_EVALID; \
@@ -408,12 +408,12 @@
  *
  * @param[in] ext ([Sized array](@ref sizedarrays)) of extensions to explore
  * @param[in] index Index in the \p ext array where to start searching (first call with 0, the consequent calls with
- *            the returned index increased by 1 (until the iteration is not terminated by returning LY_ARRAY_SIZE(ext).
+ *            the returned index increased by 1 (until the iteration is not terminated by returning LY_ARRAY_COUNT(ext).
  * @param[in] substmt Type of the extension (its belongins to the specific substatement) to iterate, use
  *            #LYEXT_SUBSTMT_ALL to go through all the extensions in the array
- * @result index in the ext array, LY_ARRAY_SIZE(ext) value if not present.
+ * @result index in the ext array, LY_ARRAY_COUNT(ext) value if not present.
  */
-LY_ARRAY_SIZE_TYPE lysp_ext_instance_iter(struct lysp_ext_instance *ext, LY_ARRAY_SIZE_TYPE index, LYEXT_SUBSTMT substmt);
+LY_ARRAY_COUNT_TYPE lysp_ext_instance_iter(struct lysp_ext_instance *ext, LY_ARRAY_COUNT_TYPE index, LYEXT_SUBSTMT substmt);
 
 /**
  * @brief Get the covering schema module structure for the given parsed module structure.
@@ -651,7 +651,7 @@
  * @brief Macro to free [sized array](@ref sizedarrays) of items using the provided free function. The ARRAY itself is also freed,
  * but the memory is not sanitized.
  */
-#define FREE_ARRAY(CTX, ARRAY, FUNC) {LY_ARRAY_SIZE_TYPE c__; LY_ARRAY_FOR(ARRAY, c__){FUNC(CTX, &(ARRAY)[c__]);}LY_ARRAY_FREE(ARRAY);}
+#define FREE_ARRAY(CTX, ARRAY, FUNC) {LY_ARRAY_COUNT_TYPE c__; LY_ARRAY_FOR(ARRAY, c__){FUNC(CTX, &(ARRAY)[c__]);}LY_ARRAY_FREE(ARRAY);}
 
 /**
  * @brief Macro to free the specified MEMBER of a structure using the provided free function. The memory is not sanitized.
@@ -662,7 +662,7 @@
  * @brief Macro to free [sized array](@ref sizedarrays) of strings stored in the context's dictionary. The ARRAY itself is also freed,
  * but the memory is not sanitized.
  */
-#define FREE_STRINGS(CTX, ARRAY) {LY_ARRAY_SIZE_TYPE c__; LY_ARRAY_FOR(ARRAY, c__){FREE_STRING(CTX, ARRAY[c__]);}LY_ARRAY_FREE(ARRAY);}
+#define FREE_STRINGS(CTX, ARRAY) {LY_ARRAY_COUNT_TYPE c__; LY_ARRAY_FOR(ARRAY, c__){FREE_STRING(CTX, ARRAY[c__]);}LY_ARRAY_FREE(ARRAY);}
 
 /**
  * @brief Free the parsed submodule structure.
diff --git a/src/validation.c b/src/validation.c
index 421863e..a4701e4 100644
--- a/src/validation.c
+++ b/src/validation.c
@@ -168,7 +168,7 @@
                 int unres_when = 0;
 
                 do {
-                    LY_ARRAY_SIZE_TYPE u;
+                    LY_ARRAY_COUNT_TYPE u;
                     LY_ARRAY_FOR(schema->when, u) {
                         ret = lyd_validate_when(tree, node, schema->when[u]);
                         if (ret) {
@@ -604,13 +604,13 @@
     struct lyd_node *diter, *first, *second;
     struct lyd_value *val1, *val2;
     char *path1, *path2, *uniq_str, *ptr;
-    LY_ARRAY_SIZE_TYPE u, v, action;
+    LY_ARRAY_COUNT_TYPE u, v, action;
 
     assert(val1_p && val2_p);
 
     first = *((struct lyd_node **)val1_p);
     second = *((struct lyd_node **)val2_p);
-    action = (LY_ARRAY_SIZE_TYPE)cb_data;
+    action = (LY_ARRAY_COUNT_TYPE)cb_data;
 
     assert(first && (first->schema->nodetype == LYS_LIST));
     assert(second && (second->schema == first->schema));
@@ -622,7 +622,7 @@
     /* compare unique leaves */
     if (action > 0) {
         u = action - 1;
-        if (u < LY_ARRAY_SIZE(slist->uniques)) {
+        if (u < LY_ARRAY_COUNT(slist->uniques)) {
             goto uniquecheck;
         }
     }
@@ -652,7 +652,7 @@
                 break;
             }
         }
-        if (v && (v == LY_ARRAY_SIZE(slist->uniques[u]))) {
+        if (v && (v == LY_ARRAY_COUNT(slist->uniques[u]))) {
             /* all unique leafs are the same in this set, create this nice error */
             path1 = lyd_path(first, LYD_PATH_LOG, NULL, 0);
             path2 = lyd_path(second, LYD_PATH_LOG, NULL, 0);
@@ -705,7 +705,7 @@
 {
     const struct lyd_node *diter;
     struct ly_set *set;
-    LY_ARRAY_SIZE_TYPE u, v, x = 0;
+    LY_ARRAY_COUNT_TYPE u, v, x = 0;
     LY_ERR ret = LY_SUCCESS;
     uint32_t hash, i, size = 0;
     int dynamic;
@@ -746,9 +746,9 @@
         i = 32 - i;
         size = 1 << i;
 
-        uniqtables = malloc(LY_ARRAY_SIZE(uniques) * sizeof *uniqtables);
+        uniqtables = malloc(LY_ARRAY_COUNT(uniques) * sizeof *uniqtables);
         LY_CHECK_ERR_GOTO(!uniqtables, LOGMEM(ctx); ret = LY_EMEM, cleanup);
-        x = LY_ARRAY_SIZE(uniques);
+        x = LY_ARRAY_COUNT(uniques);
         for (v = 0; v < x; v++) {
             uniqtables[v] = lyht_new(size, sizeof(struct lyd_node *), lyd_val_uniq_list_equal, (void *)(v + 1L), 0);
             LY_CHECK_ERR_GOTO(!uniqtables[v], LOGMEM(ctx); ret = LY_EMEM, cleanup);
@@ -758,7 +758,7 @@
             /* loop for unique - get the hash for the instances */
             for (u = 0; u < x; u++) {
                 val = NULL;
-                for (v = hash = 0; v < LY_ARRAY_SIZE(uniques[u]); v++) {
+                for (v = hash = 0; v < LY_ARRAY_COUNT(uniques[u]); v++) {
                     diter = lyd_val_uniq_find_leaf(uniques[u][v], set->objs[i]);
                     if (diter) {
                         val = &((struct lyd_node_term *)diter)->value;
@@ -900,7 +900,7 @@
     struct lyxp_set xp_set;
     struct lysc_must *musts;
     const struct lyd_node *tree;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     switch (node->schema->nodetype) {
     case LYS_CONTAINER:
@@ -1044,7 +1044,7 @@
     const struct lysc_node *iter = NULL;
     struct lyd_node *node;
     struct lyd_value **dflts;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     assert(first && (parent || sparent || mod) && node_types && node_when);
 
diff --git a/src/xml.c b/src/xml.c
index b4670f6..9f062ed 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -1129,7 +1129,7 @@
 lyxml_get_prefixes(struct lyxml_ctx *xmlctx, const char *value, size_t value_len, struct ly_prefix **val_prefs)
 {
     LY_ERR ret;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     uint32_t c;
     const struct lyxml_ns *ns;
     const char *start, *stop;
@@ -1184,7 +1184,7 @@
 lyxml_value_compare(const char *value1, const struct ly_prefix *prefs1, const char *value2, const struct ly_prefix *prefs2)
 {
     const char *ptr1, *ptr2, *ns1, *ns2;
-    LY_ARRAY_SIZE_TYPE u1, u2;
+    LY_ARRAY_COUNT_TYPE u1, u2;
     int len;
 
     if (!value1 && !value2) {
diff --git a/src/xpath.c b/src/xpath.c
index 4160656..954cd51 100644
--- a/src/xpath.c
+++ b/src/xpath.c
@@ -2997,7 +2997,7 @@
 {
     struct lysc_type_union *uni;
     int ret;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     switch (type->basetype) {
     case LY_TYPE_DEC64:
@@ -3039,7 +3039,7 @@
 {
     struct lysc_type_union *uni;
     int ret;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     switch (type->basetype) {
     case LY_TYPE_BITS:
@@ -3078,7 +3078,7 @@
 {
     struct lysc_type_union *uni;
     int ret;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     if (type->basetype == base) {
         return 1;
@@ -3112,7 +3112,7 @@
 {
     struct lysc_type_union *uni;
     int found = 0;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     switch (type->basetype) {
     case LY_TYPE_UNION:
@@ -3319,7 +3319,7 @@
     struct lysc_node_leaf *sleaf;
     struct lysc_type_bits *bits;
     LY_ERR rc = LY_SUCCESS;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
 
     if (options & LYXP_SCNODE_ALL) {
         if ((args[0]->type != LYXP_SET_SCNODE_SET) || !(sleaf = (struct lysc_node_leaf *)warn_get_scnode_in_ctx(args[0]))) {
@@ -3654,7 +3654,7 @@
             assert(!rc);
 
             /* get the target node */
-            target = p[LY_ARRAY_SIZE(p) - 1].node;
+            target = p[LY_ARRAY_COUNT(p) - 1].node;
             ly_path_free(set->ctx, p);
 
             lyxp_set_scnode_insert_node(set, target, LYXP_NODE_ELEM);
@@ -3716,7 +3716,7 @@
 xpath_derived_from(struct lyxp_set **args, uint16_t UNUSED(arg_count), struct lyxp_set *set, int options)
 {
     uint16_t i;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     struct lyd_node_term *leaf;
     struct lysc_node_leaf *sleaf;
     struct lyd_value data = {0};
@@ -3799,7 +3799,7 @@
 xpath_derived_from_or_self(struct lyxp_set **args, uint16_t UNUSED(arg_count), struct lyxp_set *set, int options)
 {
     uint16_t i;
-    LY_ARRAY_SIZE_TYPE u;
+    LY_ARRAY_COUNT_TYPE u;
     struct lyd_node_term *leaf;
     struct lysc_node_leaf *sleaf;
     struct lyd_value data = {0};