diff --git a/CMakeLists.txt b/CMakeLists.txt
index f8a74ba..e2d1dbd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -158,6 +158,8 @@
     src/set.c
     src/context.c
     src/tree_schema.c
+    src/tree_schema_free.c
+    src/tree_schema_compile.c
     src/tree_schema_helpers.c
     src/parser_yang.c
     src/xml.c
diff --git a/src/tree_schema.c b/src/tree_schema.c
index b224048..cacadf7 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -30,745 +30,11 @@
 #include "tree_schema_internal.h"
 #include "xpath.h"
 
-const char* ly_data_type2str[LY_DATA_TYPE_COUNT] = {"unknown", "binary", "bits", "boolean", "decimal64", "empty", "enumeration",
-    "identityref", "instance-identifier", "leafref", "string", "union", "8bit integer", "8bit unsigned integer", "16bit integer",
-    "16bit unsigned integer", "32bit integer", "32bit unsigned integer", "64bit integer", "64bit unsigned integer"
-};
-
-#define FREE_ARRAY(CTX, ARRAY, FUNC) {uint64_t c__; LY_ARRAY_FOR(ARRAY, c__){FUNC(CTX, &(ARRAY)[c__]);}LY_ARRAY_FREE(ARRAY);}
-#define FREE_MEMBER(CTX, MEMBER, FUNC) if (MEMBER) {FUNC(CTX, MEMBER);free(MEMBER);}
-#define FREE_STRING(CTX, STRING) if (STRING) {lydict_remove(CTX, STRING);}
-#define FREE_STRINGS(CTX, ARRAY) {uint64_t c__; LY_ARRAY_FOR(ARRAY, c__){FREE_STRING(CTX, ARRAY[c__]);}LY_ARRAY_FREE(ARRAY);}
-
-#define DUP_STRING(CTX, DUP, ORIG) if (ORIG) {DUP = lydict_insert(CTX, ORIG, 0);}
-
-#define COMPILE_ARRAY_GOTO(CTX, ARRAY_P, ARRAY_C, OPTIONS, ITER, FUNC, RET, GOTO) \
-    if (ARRAY_P) { \
-        LY_ARRAY_CREATE_GOTO((CTX)->ctx, ARRAY_C, LY_ARRAY_SIZE(ARRAY_P), RET, GOTO); \
-        for (ITER = 0; ITER < LY_ARRAY_SIZE(ARRAY_P); ++ITER) { \
-            LY_ARRAY_INCREMENT(ARRAY_C); \
-            RET = FUNC(CTX, &(ARRAY_P)[ITER], OPTIONS, &(ARRAY_C)[ITER]); \
-            LY_CHECK_GOTO(RET != LY_SUCCESS, GOTO); \
-        } \
-    }
-
-#define COMPILE_MEMBER_GOTO(CTX, MEMBER_P, MEMBER_C, OPTIONS, FUNC, RET, GOTO) \
-    if (MEMBER_P) { \
-        MEMBER_C = calloc(1, sizeof *(MEMBER_C)); \
-        LY_CHECK_ERR_GOTO(!(MEMBER_C), LOGMEM((CTX)->ctx); RET = LY_EMEM, GOTO); \
-        RET = FUNC(CTX, MEMBER_P, OPTIONS, MEMBER_C); \
-        LY_CHECK_GOTO(RET != LY_SUCCESS, GOTO); \
-    }
-
-static void lysp_grp_free(struct ly_ctx *ctx, struct lysp_grp *grp);
-static void lysp_node_free(struct ly_ctx *ctx, struct lysp_node *node);
-
-static void
-lysp_stmt_free(struct ly_ctx *ctx, struct lysp_stmt *stmt)
+API int
+lysc_feature_value(const struct lysc_feature *feature)
 {
-    struct lysp_stmt *child, *next;
-
-    FREE_STRING(ctx, stmt->stmt);
-    FREE_STRING(ctx, stmt->arg);
-
-    LY_LIST_FOR_SAFE(stmt->child, next, child) {
-        lysp_stmt_free(ctx, child);
-    }
-
-    free(stmt);
-}
-
-static void
-lysp_ext_instance_free(struct ly_ctx *ctx, struct lysp_ext_instance *ext)
-{
-    struct lysp_stmt *stmt, *next;
-
-    FREE_STRING(ctx, ext->name);
-    FREE_STRING(ctx, ext->argument);
-
-    LY_LIST_FOR_SAFE(ext->child, next, stmt) {
-        lysp_stmt_free(ctx, stmt);
-    }
-}
-
-static void
-lysp_import_free(struct ly_ctx *ctx, struct lysp_import *import)
-{
-    /* imported module is freed directly from the context's list */
-    FREE_STRING(ctx, import->name);
-    FREE_STRING(ctx, import->prefix);
-    FREE_STRING(ctx, import->dsc);
-    FREE_STRING(ctx, import->ref);
-    FREE_ARRAY(ctx, import->exts, lysp_ext_instance_free);
-}
-
-static void
-lysp_include_free(struct ly_ctx *ctx, struct lysp_include *include)
-{
-    if (include->submodule) {
-        lysp_module_free(include->submodule);
-    }
-    FREE_STRING(ctx, include->name);
-    FREE_STRING(ctx, include->dsc);
-    FREE_STRING(ctx, include->ref);
-    FREE_ARRAY(ctx, include->exts, lysp_ext_instance_free);
-}
-
-static void
-lysp_revision_free(struct ly_ctx *ctx, struct lysp_revision *rev)
-{
-    FREE_STRING(ctx, rev->dsc);
-    FREE_STRING(ctx, rev->ref);
-    FREE_ARRAY(ctx, rev->exts, lysp_ext_instance_free);
-}
-
-static void
-lysp_ext_free(struct ly_ctx *ctx, struct lysp_ext *ext)
-{
-    FREE_STRING(ctx, ext->name);
-    FREE_STRING(ctx, ext->argument);
-    FREE_STRING(ctx, ext->dsc);
-    FREE_STRING(ctx, ext->ref);
-    FREE_ARRAY(ctx, ext->exts, lysp_ext_instance_free);
-}
-
-static void
-lysp_feature_free(struct ly_ctx *ctx, struct lysp_feature *feat)
-{
-    FREE_STRING(ctx, feat->name);
-    FREE_STRINGS(ctx, feat->iffeatures);
-    FREE_STRING(ctx, feat->dsc);
-    FREE_STRING(ctx, feat->ref);
-    FREE_ARRAY(ctx, feat->exts, lysp_ext_instance_free);
-}
-
-static void
-lysp_ident_free(struct ly_ctx *ctx, struct lysp_ident *ident)
-{
-    FREE_STRING(ctx, ident->name);
-    FREE_STRINGS(ctx, ident->iffeatures);
-    FREE_STRINGS(ctx, ident->bases);
-    FREE_STRING(ctx, ident->dsc);
-    FREE_STRING(ctx, ident->ref);
-    FREE_ARRAY(ctx, ident->exts, lysp_ext_instance_free);
-}
-
-static void
-lysp_restr_free(struct ly_ctx *ctx, struct lysp_restr *restr)
-{
-    FREE_STRING(ctx, restr->arg);
-    FREE_STRING(ctx, restr->emsg);
-    FREE_STRING(ctx, restr->eapptag);
-    FREE_STRING(ctx, restr->dsc);
-    FREE_STRING(ctx, restr->ref);
-    FREE_ARRAY(ctx, restr->exts, lysp_ext_instance_free);
-}
-
-static void
-lysp_type_enum_free(struct ly_ctx *ctx, struct lysp_type_enum *item)
-{
-    FREE_STRING(ctx, item->name);
-    FREE_STRING(ctx, item->dsc);
-    FREE_STRING(ctx, item->ref);
-    FREE_STRINGS(ctx, item->iffeatures);
-    FREE_ARRAY(ctx, item->exts, lysp_ext_instance_free);
-}
-
-static void lysc_type_free(struct ly_ctx *ctx, struct lysc_type *type);
-static void
-lysp_type_free(struct ly_ctx *ctx, struct lysp_type *type)
-{
-    FREE_STRING(ctx, type->name);
-    FREE_MEMBER(ctx, type->range, lysp_restr_free);
-    FREE_MEMBER(ctx, type->length, lysp_restr_free);
-    FREE_ARRAY(ctx, type->patterns, lysp_restr_free);
-    FREE_ARRAY(ctx, type->enums, lysp_type_enum_free);
-    FREE_ARRAY(ctx, type->bits, lysp_type_enum_free);
-    FREE_STRING(ctx, type->path);
-    FREE_STRINGS(ctx, type->bases);
-    FREE_ARRAY(ctx, type->types, lysp_type_free);
-    FREE_ARRAY(ctx, type->exts, lysp_ext_instance_free);
-    if (type->compiled) {
-        lysc_type_free(ctx, type->compiled);
-    }
-}
-
-static void
-lysp_tpdf_free(struct ly_ctx *ctx, struct lysp_tpdf *tpdf)
-{
-    FREE_STRING(ctx, tpdf->name);
-    FREE_STRING(ctx, tpdf->units);
-    FREE_STRING(ctx, tpdf->dflt);
-    FREE_STRING(ctx, tpdf->dsc);
-    FREE_STRING(ctx, tpdf->ref);
-    FREE_ARRAY(ctx, tpdf->exts, lysp_ext_instance_free);
-
-    lysp_type_free(ctx, &tpdf->type);
-
-}
-
-static void
-lysp_action_inout_free(struct ly_ctx *ctx, struct lysp_action_inout *inout)
-{
-    struct lysp_node *node, *next;
-
-    FREE_ARRAY(ctx, inout->musts, lysp_restr_free);
-    FREE_ARRAY(ctx, inout->typedefs, lysp_tpdf_free);
-    FREE_ARRAY(ctx, inout->groupings, lysp_grp_free);
-    LY_LIST_FOR_SAFE(inout->data, next, node) {
-        lysp_node_free(ctx, node);
-    }
-    FREE_ARRAY(ctx, inout->exts, lysp_ext_instance_free);
-
-}
-
-static void
-lysp_action_free(struct ly_ctx *ctx, struct lysp_action *action)
-{
-    FREE_STRING(ctx, action->name);
-    FREE_STRING(ctx, action->dsc);
-    FREE_STRING(ctx, action->ref);
-    FREE_STRINGS(ctx, action->iffeatures);
-    FREE_ARRAY(ctx, action->typedefs, lysp_tpdf_free);
-    FREE_ARRAY(ctx, action->groupings, lysp_grp_free);
-    FREE_MEMBER(ctx, action->input, lysp_action_inout_free);
-    FREE_MEMBER(ctx, action->output, lysp_action_inout_free);
-    FREE_ARRAY(ctx, action->exts, lysp_ext_instance_free);
-}
-
-static void
-lysp_notif_free(struct ly_ctx *ctx, struct lysp_notif *notif)
-{
-    struct lysp_node *node, *next;
-
-    FREE_STRING(ctx, notif->name);
-    FREE_STRING(ctx, notif->dsc);
-    FREE_STRING(ctx, notif->ref);
-    FREE_STRINGS(ctx, notif->iffeatures);
-    FREE_ARRAY(ctx, notif->musts, lysp_restr_free);
-    FREE_ARRAY(ctx, notif->typedefs, lysp_tpdf_free);
-    FREE_ARRAY(ctx, notif->groupings, lysp_grp_free);
-    LY_LIST_FOR_SAFE(notif->data, next, node) {
-        lysp_node_free(ctx, node);
-    }
-    FREE_ARRAY(ctx, notif->exts, lysp_ext_instance_free);
-}
-
-static void
-lysp_grp_free(struct ly_ctx *ctx, struct lysp_grp *grp)
-{
-    struct lysp_node *node, *next;
-
-    FREE_STRING(ctx, grp->name);
-    FREE_STRING(ctx, grp->dsc);
-    FREE_STRING(ctx, grp->ref);
-    FREE_ARRAY(ctx, grp->typedefs, lysp_tpdf_free);
-    FREE_ARRAY(ctx, grp->groupings, lysp_grp_free);
-    LY_LIST_FOR_SAFE(grp->data, next, node) {
-        lysp_node_free(ctx, node);
-    }
-    FREE_ARRAY(ctx, grp->actions, lysp_action_free);
-    FREE_ARRAY(ctx, grp->notifs, lysp_notif_free);
-    FREE_ARRAY(ctx, grp->exts, lysp_ext_instance_free);
-}
-
-static void
-lysp_when_free(struct ly_ctx *ctx, struct lysp_when *when)
-{
-    FREE_STRING(ctx, when->cond);
-    FREE_STRING(ctx, when->dsc);
-    FREE_STRING(ctx, when->ref);
-    FREE_ARRAY(ctx, when->exts, lysp_ext_instance_free);
-}
-
-static void
-lysp_augment_free(struct ly_ctx *ctx, struct lysp_augment *augment)
-{
-    struct lysp_node *node, *next;
-
-    FREE_STRING(ctx, augment->nodeid);
-    FREE_STRING(ctx, augment->dsc);
-    FREE_STRING(ctx, augment->ref);
-    FREE_MEMBER(ctx, augment->when, lysp_when_free);
-    FREE_STRINGS(ctx, augment->iffeatures);
-    LY_LIST_FOR_SAFE(augment->child, next, node) {
-        lysp_node_free(ctx, node);
-    }
-    FREE_ARRAY(ctx, augment->actions, lysp_action_free);
-    FREE_ARRAY(ctx, augment->notifs, lysp_notif_free);
-    FREE_ARRAY(ctx, augment->exts, lysp_ext_instance_free);
-}
-
-static void
-lysp_deviate_free(struct ly_ctx *ctx, struct lysp_deviate *d)
-{
-    struct lysp_deviate_add *add = (struct lysp_deviate_add*)d;
-    struct lysp_deviate_rpl *rpl = (struct lysp_deviate_rpl*)d;
-
-    FREE_ARRAY(ctx, d->exts, lysp_ext_instance_free);
-    switch(d->mod) {
-    case LYS_DEV_NOT_SUPPORTED:
-        /* nothing to do */
-        break;
-    case LYS_DEV_ADD:
-    case LYS_DEV_DELETE: /* compatible for dynamically allocated data */
-        FREE_STRING(ctx, add->units);
-        FREE_ARRAY(ctx, add->musts, lysp_restr_free);
-        FREE_STRINGS(ctx, add->uniques);
-        FREE_STRINGS(ctx, add->dflts);
-        break;
-    case LYS_DEV_REPLACE:
-        FREE_MEMBER(ctx, rpl->type, lysp_type_free);
-        FREE_STRING(ctx, rpl->units);
-        FREE_STRING(ctx, rpl->dflt);
-        break;
-    default:
-        LOGINT(ctx);
-        break;
-    }
-}
-
-static void
-lysp_deviation_free(struct ly_ctx *ctx, struct lysp_deviation *dev)
-{
-    struct lysp_deviate *next, *iter;
-
-    FREE_STRING(ctx, dev->nodeid);
-    FREE_STRING(ctx, dev->dsc);
-    FREE_STRING(ctx, dev->ref);
-    LY_LIST_FOR_SAFE(dev->deviates, next, iter) {
-        lysp_deviate_free(ctx, iter);
-        free(iter);
-    }
-    FREE_ARRAY(ctx, dev->exts, lysp_ext_instance_free);
-}
-
-static void
-lysp_refine_free(struct ly_ctx *ctx, struct lysp_refine *ref)
-{
-    FREE_STRING(ctx, ref->nodeid);
-    FREE_STRING(ctx, ref->dsc);
-    FREE_STRING(ctx, ref->ref);
-    FREE_STRINGS(ctx, ref->iffeatures);
-    FREE_ARRAY(ctx, ref->musts, lysp_restr_free);
-    FREE_STRING(ctx, ref->presence);
-    FREE_STRINGS(ctx, ref->dflts);
-    FREE_ARRAY(ctx, ref->exts, lysp_ext_instance_free);
-}
-
-static void
-lysp_node_free(struct ly_ctx *ctx, struct lysp_node *node)
-{
-    struct lysp_node *child, *next;
-
-    FREE_STRING(ctx, node->name);
-    FREE_STRING(ctx, node->dsc);
-    FREE_STRING(ctx, node->ref);
-    FREE_MEMBER(ctx, node->when, lysp_when_free);
-    FREE_STRINGS(ctx, node->iffeatures);
-    FREE_ARRAY(ctx, node->exts, lysp_ext_instance_free);
-
-    switch(node->nodetype) {
-    case LYS_CONTAINER:
-        FREE_ARRAY(ctx, ((struct lysp_node_container*)node)->musts, lysp_restr_free);
-        FREE_STRING(ctx, ((struct lysp_node_container*)node)->presence);
-        FREE_ARRAY(ctx, ((struct lysp_node_container*)node)->typedefs, lysp_tpdf_free);
-        FREE_ARRAY(ctx, ((struct lysp_node_container*)node)->groupings, lysp_grp_free);
-        LY_LIST_FOR_SAFE(((struct lysp_node_container*)node)->child, next, child) {
-            lysp_node_free(ctx, child);
-        }
-        FREE_ARRAY(ctx, ((struct lysp_node_container*)node)->actions, lysp_action_free);
-        FREE_ARRAY(ctx, ((struct lysp_node_container*)node)->notifs, lysp_notif_free);
-        break;
-    case LYS_LEAF:
-        FREE_ARRAY(ctx, ((struct lysp_node_leaf*)node)->musts, lysp_restr_free);
-        lysp_type_free(ctx, &((struct lysp_node_leaf*)node)->type);
-        FREE_STRING(ctx, ((struct lysp_node_leaf*)node)->units);
-        FREE_STRING(ctx, ((struct lysp_node_leaf*)node)->dflt);
-        break;
-    case LYS_LEAFLIST:
-        FREE_ARRAY(ctx, ((struct lysp_node_leaflist*)node)->musts, lysp_restr_free);
-        lysp_type_free(ctx, &((struct lysp_node_leaflist*)node)->type);
-        FREE_STRING(ctx, ((struct lysp_node_leaflist*)node)->units);
-        FREE_STRINGS(ctx, ((struct lysp_node_leaflist*)node)->dflts);
-        break;
-    case LYS_LIST:
-        FREE_ARRAY(ctx, ((struct lysp_node_list*)node)->musts, lysp_restr_free);
-        FREE_STRING(ctx, ((struct lysp_node_list*)node)->key);
-        FREE_ARRAY(ctx, ((struct lysp_node_list*)node)->typedefs, lysp_tpdf_free);
-        FREE_ARRAY(ctx, ((struct lysp_node_list*)node)->groupings,  lysp_grp_free);
-        LY_LIST_FOR_SAFE(((struct lysp_node_list*)node)->child, next, child) {
-            lysp_node_free(ctx, child);
-        }
-        FREE_ARRAY(ctx, ((struct lysp_node_list*)node)->actions, lysp_action_free);
-        FREE_ARRAY(ctx, ((struct lysp_node_list*)node)->notifs, lysp_notif_free);
-        FREE_STRINGS(ctx, ((struct lysp_node_list*)node)->uniques);
-        break;
-    case LYS_CHOICE:
-        LY_LIST_FOR_SAFE(((struct lysp_node_choice*)node)->child, next, child) {
-            lysp_node_free(ctx, child);
-        }
-        FREE_STRING(ctx, ((struct lysp_node_choice*)node)->dflt);
-        break;
-    case LYS_CASE:
-        LY_LIST_FOR_SAFE(((struct lysp_node_case*)node)->child, next, child) {
-            lysp_node_free(ctx, child);
-        }
-        break;
-    case LYS_ANYDATA:
-    case LYS_ANYXML:
-        FREE_ARRAY(ctx, ((struct lysp_node_anydata*)node)->musts, lysp_restr_free);
-        break;
-    case LYS_USES:
-        FREE_ARRAY(ctx, ((struct lysp_node_uses*)node)->refines, lysp_refine_free);
-        FREE_ARRAY(ctx, ((struct lysp_node_uses*)node)->augments, lysp_augment_free);
-        break;
-    default:
-        LOGINT(ctx);
-    }
-
-    free(node);
-}
-
-API void
-lysp_module_free(struct lysp_module *module)
-{
-    struct ly_ctx *ctx;
-    struct lysp_node *node, *next;
-
-    LY_CHECK_ARG_RET(NULL, module,);
-    ctx = module->ctx;
-
-    FREE_STRING(ctx, module->name);
-    FREE_STRING(ctx, module->filepath);
-    FREE_STRING(ctx, module->ns);  /* or belongs-to */
-    FREE_STRING(ctx, module->prefix);
-
-    FREE_ARRAY(ctx, module->imports, lysp_import_free);
-    FREE_ARRAY(ctx, module->includes, lysp_include_free);
-
-    FREE_STRING(ctx, module->org);
-    FREE_STRING(ctx, module->contact);
-    FREE_STRING(ctx, module->dsc);
-    FREE_STRING(ctx, module->ref);
-
-    FREE_ARRAY(ctx, module->revs, lysp_revision_free);
-    FREE_ARRAY(ctx, module->extensions, lysp_ext_free);
-    FREE_ARRAY(ctx, module->features, lysp_feature_free);
-    FREE_ARRAY(ctx, module->identities, lysp_ident_free);
-    FREE_ARRAY(ctx, module->typedefs, lysp_tpdf_free);
-    FREE_ARRAY(ctx, module->groupings, lysp_grp_free);
-    LY_LIST_FOR_SAFE(module->data, next, node) {
-        lysp_node_free(ctx, node);
-    }
-    FREE_ARRAY(ctx, module->augments, lysp_augment_free);
-    FREE_ARRAY(ctx, module->rpcs, lysp_action_free);
-    FREE_ARRAY(ctx, module->notifs, lysp_notif_free);
-    FREE_ARRAY(ctx, module->deviations, lysp_deviation_free);
-    FREE_ARRAY(ctx, module->exts, lysp_ext_instance_free);
-
-    free(module);
-}
-
-static struct lysc_ext_instance *
-lysc_ext_instance_dup(struct ly_ctx *ctx, struct lysc_ext_instance *orig)
-{
-    /* TODO */
-    (void) ctx;
-    (void) orig;
-    return NULL;
-}
-
-static void
-lysc_ext_instance_free(struct ly_ctx *ctx, struct lysc_ext_instance *ext)
-{
-    FREE_STRING(ctx, ext->argument);
-    FREE_ARRAY(ctx, ext->exts, lysc_ext_instance_free);
-}
-
-static void
-lysc_iffeature_free(struct ly_ctx *UNUSED(ctx), struct lysc_iffeature *iff)
-{
-    LY_ARRAY_FREE(iff->features);
-    free(iff->expr);
-}
-
-static void
-lysc_import_free(struct ly_ctx *ctx, struct lysc_import *import)
-{
-    /* imported module is freed directly from the context's list */
-    FREE_STRING(ctx, import->prefix);
-    FREE_ARRAY(ctx, import->exts, lysc_ext_instance_free);
-}
-
-static void
-lysc_ident_free(struct ly_ctx *ctx, struct lysc_ident *ident)
-{
-    FREE_STRING(ctx, ident->name);
-    FREE_ARRAY(ctx, ident->iffeatures, lysc_iffeature_free);
-    LY_ARRAY_FREE(ident->derived);
-    FREE_ARRAY(ctx, ident->exts, lysc_ext_instance_free);
-}
-
-static void
-lysc_feature_free(struct ly_ctx *ctx, struct lysc_feature *feat)
-{
-    FREE_STRING(ctx, feat->name);
-    FREE_ARRAY(ctx, feat->iffeatures, lysc_iffeature_free);
-    LY_ARRAY_FREE(feat->depfeatures);
-    FREE_ARRAY(ctx, feat->exts, lysc_ext_instance_free);
-}
-
-struct lysc_range*
-lysc_range_dup(struct ly_ctx *ctx, const struct lysc_range *orig)
-{
-    struct lysc_range *dup;
-    LY_ERR ret;
-
-    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);
-    }
-    DUP_STRING(ctx, dup->eapptag, orig->eapptag);
-    DUP_STRING(ctx, dup->emsg, orig->emsg);
-    dup->exts = lysc_ext_instance_dup(ctx, orig->exts);
-
-    return dup;
-cleanup:
-    free(dup);
-    (void) ret; /* set but not used due to the return type */
-    return NULL;
-}
-
-static void
-lysc_range_free(struct ly_ctx *ctx, struct lysc_range *range)
-{
-    LY_ARRAY_FREE(range->parts);
-    FREE_STRING(ctx, range->eapptag);
-    FREE_STRING(ctx, range->emsg);
-    FREE_ARRAY(ctx, range->exts, lysc_ext_instance_free);
-}
-
-struct lysc_pattern*
-lysc_pattern_dup(struct lysc_pattern *orig)
-{
-    ++orig->refcount;
-    return orig;
-}
-
-struct lysc_pattern**
-lysc_patterns_dup(struct ly_ctx *ctx, struct lysc_pattern **orig)
-{
-    struct lysc_pattern **dup;
-    unsigned int u;
-
-    LY_ARRAY_CREATE_RET(ctx, dup, LY_ARRAY_SIZE(orig), NULL);
-    LY_ARRAY_FOR(orig, u) {
-        dup[u] = lysc_pattern_dup(orig[u]);
-        LY_ARRAY_INCREMENT(dup);
-    }
-    return dup;
-}
-
-static void
-lysc_pattern_free(struct ly_ctx *ctx, struct lysc_pattern **pattern)
-{
-    if (--(*pattern)->refcount) {
-        return;
-    }
-    pcre_free((*pattern)->expr);
-    pcre_free_study((*pattern)->expr_extra);
-    FREE_STRING(ctx, (*pattern)->eapptag);
-    FREE_STRING(ctx, (*pattern)->emsg);
-    FREE_ARRAY(ctx, (*pattern)->exts, lysc_ext_instance_free);
-    free(*pattern);
-}
-
-static void
-lysc_enum_item_free(struct ly_ctx *ctx, struct lysc_type_enum_item *item)
-{
-    FREE_STRING(ctx, item->name);
-    FREE_ARRAY(ctx, item->iffeatures, lysc_iffeature_free);
-    FREE_ARRAY(ctx, item->exts, lysc_ext_instance_free);
-}
-
-static void
-lysc_type_free(struct ly_ctx *ctx, struct lysc_type *type)
-{
-    if (--type->refcount) {
-        return;
-    }
-    switch(type->basetype) {
-    case LY_TYPE_BINARY:
-        FREE_MEMBER(ctx, ((struct lysc_type_bin*)type)->length, lysc_range_free);
-        break;
-    case LY_TYPE_BITS:
-        FREE_ARRAY(ctx, (struct lysc_type_enum_item*)((struct lysc_type_bits*)type)->bits, lysc_enum_item_free);
-        break;
-    case LY_TYPE_STRING:
-        FREE_MEMBER(ctx, ((struct lysc_type_str*)type)->length, lysc_range_free);
-        FREE_ARRAY(ctx, ((struct lysc_type_str*)type)->patterns, lysc_pattern_free);
-        break;
-    case LY_TYPE_ENUM:
-        FREE_ARRAY(ctx, ((struct lysc_type_enum*)type)->enums, lysc_enum_item_free);
-        break;
-    case LY_TYPE_INT8:
-    case LY_TYPE_UINT8:
-    case LY_TYPE_INT16:
-    case LY_TYPE_UINT16:
-    case LY_TYPE_INT32:
-    case LY_TYPE_UINT32:
-    case LY_TYPE_INT64:
-    case LY_TYPE_UINT64:
-        FREE_MEMBER(ctx, ((struct lysc_type_num*)type)->range, lysc_range_free);
-        break;
-    case LY_TYPE_BOOL:
-    case LY_TYPE_EMPTY:
-    case LY_TYPE_UNKNOWN: /* just to complete switch */
-        /* nothing to do */
-        break;
-    }
-    FREE_ARRAY(ctx, type->exts, lysc_ext_instance_free);
-
-    free(type);
-}
-
-static void lysc_node_free(struct ly_ctx *ctx, struct lysc_node *node);
-
-static void
-lysc_node_container_free(struct ly_ctx *ctx, struct lysc_node_container *node)
-{
-    struct lysc_node *child, *child_next;
-
-    LY_LIST_FOR_SAFE(node->child, child_next, child) {
-        lysc_node_free(ctx, child);
-    }
-}
-
-static void
-lysc_node_leaf_free(struct ly_ctx *ctx, struct lysc_node_leaf *node)
-{
-    if (node->type) {
-        lysc_type_free(ctx, node->type);
-    }
-}
-
-static void
-lysc_node_free(struct ly_ctx *ctx, struct lysc_node *node)
-{
-    /* common part */
-    FREE_STRING(ctx, node->name);
-
-    /* nodetype-specific part */
-    switch(node->nodetype) {
-    case LYS_CONTAINER:
-        lysc_node_container_free(ctx, (struct lysc_node_container*)node);
-        break;
-    case LYS_LEAF:
-        lysc_node_leaf_free(ctx, (struct lysc_node_leaf*)node);
-        break;
-    default:
-        LOGINT(ctx);
-    }
-
-    free(node);
-}
-
-static void
-lysc_module_free_(struct lysc_module *module)
-{
-    struct ly_ctx *ctx;
-    struct lysc_node *node, *node_next;
-
-    LY_CHECK_ARG_RET(NULL, module,);
-    ctx = module->ctx;
-
-    FREE_STRING(ctx, module->name);
-    FREE_STRING(ctx, module->ns);
-    FREE_STRING(ctx, module->prefix);
-    FREE_STRING(ctx, module->revision);
-
-    FREE_ARRAY(ctx, module->imports, lysc_import_free);
-    FREE_ARRAY(ctx, module->features, lysc_feature_free);
-    FREE_ARRAY(ctx, module->identities, lysc_ident_free);
-
-    LY_LIST_FOR_SAFE(module->data, node_next, node) {
-        lysc_node_free(ctx, node);
-    }
-
-    FREE_ARRAY(ctx, module->exts, lysc_ext_instance_free);
-
-    free(module);
-}
-
-API void
-lysc_module_free(struct lysc_module *module, void (*private_destructor)(const struct lysc_node *node, void *priv))
-{
-    if (module) {
-        lysc_module_free_(module);
-    }
-}
-
-void
-lys_module_free(struct lys_module *module, void (*private_destructor)(const struct lysc_node *node, void *priv))
-{
-    if (!module) {
-        return;
-    }
-
-    lysc_module_free(module->compiled, private_destructor);
-    lysp_module_free(module->parsed);
-    free(module);
-}
-
-struct iff_stack {
-    int size;
-    int index;     /* first empty item */
-    uint8_t *stack;
-};
-
-static LY_ERR
-iff_stack_push(struct iff_stack *stack, uint8_t value)
-{
-    if (stack->index == stack->size) {
-        stack->size += 4;
-        stack->stack = ly_realloc(stack->stack, stack->size * sizeof *stack->stack);
-        LY_CHECK_ERR_RET(!stack->stack, LOGMEM(NULL); stack->size = 0, LY_EMEM);
-    }
-    stack->stack[stack->index++] = value;
-    return LY_SUCCESS;
-}
-
-static uint8_t
-iff_stack_pop(struct iff_stack *stack)
-{
-    stack->index--;
-    return stack->stack[stack->index];
-}
-
-static void
-iff_stack_clean(struct iff_stack *stack)
-{
-    stack->size = 0;
-    free(stack->stack);
-}
-
-static void
-iff_setop(uint8_t *list, uint8_t op, int pos)
-{
-    uint8_t *item;
-    uint8_t mask = 3;
-
-    assert(pos >= 0);
-    assert(op <= 3); /* max 2 bits */
-
-    item = &list[pos / 4];
-    mask = mask << 2 * (pos % 4);
-    *item = (*item) & ~mask;
-    *item = (*item) | (op << 2 * (pos % 4));
+    LY_CHECK_ARG_RET(NULL, feature, -1);
+    return feature->flags & LYS_FENABLED ? 1 : 0;
 }
 
 static uint8_t
@@ -784,44 +50,6 @@
     return result >> 2 * (pos % 4);
 }
 
-#define LYS_IFF_LP 0x04 /* ( */
-#define LYS_IFF_RP 0x08 /* ) */
-
-API int
-lysc_feature_value(const struct lysc_feature *feature)
-{
-    LY_CHECK_ARG_RET(NULL, feature, -1);
-    return feature->flags & LYS_FENABLED ? 1 : 0;
-}
-
-static struct lysc_feature *
-lysc_feature_find(struct lysc_module *mod, const char *name, size_t len)
-{
-    size_t i;
-    struct lysc_feature *f;
-
-    for (i = 0; i < len; ++i) {
-        if (name[i] == ':') {
-            /* we have a prefixed feature */
-            mod = lysc_module_find_prefix(mod, name, i);
-            LY_CHECK_RET(!mod, NULL);
-
-            name = &name[i + 1];
-            len = len - i - 1;
-        }
-    }
-
-    /* we have the correct module, get the feature */
-    LY_ARRAY_FOR(mod->features, i) {
-        f = &mod->features[i];
-        if (!strncmp(f->name, name, len) && f->name[len] == '\0') {
-            return f;
-        }
-    }
-
-    return NULL;
-}
-
 static int
 lysc_iffeature_value_(const struct lysc_iffeature *iff, int *index_e, int *index_f)
 {
@@ -865,9 +93,6 @@
     return 0;
 }
 
-/*
- * op: 1 - enable, 0 - disable
- */
 /**
  * @brief Enable/Disable the specified feature in the module.
  *
@@ -1057,1829 +282,6 @@
     return -1;
 }
 
-static LY_ERR
-lys_compile_ext(struct lysc_ctx *ctx, struct lysp_ext_instance *ext_p, int UNUSED(options), struct lysc_ext_instance *ext)
-{
-    const char *name;
-    unsigned int u;
-    const struct lys_module *mod;
-    struct lysp_ext *edef = NULL;
-
-    DUP_STRING(ctx->ctx, ext->argument, ext_p->argument);
-    ext->insubstmt = ext_p->insubstmt;
-    ext->insubstmt_index = ext_p->insubstmt_index;
-
-    /* get module where the extension definition should be placed */
-    for (u = 0; ext_p->name[u] != ':'; ++u);
-    mod = lys_module_find_prefix(ctx->mod, ext_p->name, u);
-    LY_CHECK_ERR_RET(!mod, LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-                                  "Invalid prefix \"%.*s\" used for extension instance identifier.", u, ext_p->name),
-                     LY_EVALID);
-    LY_CHECK_ERR_RET(!mod->parsed->extensions,
-                     LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-                            "Extension instance \"%s\" refers \"%s\" module that does not contain extension definitions.",
-                            ext_p->name, mod->parsed->name),
-                     LY_EVALID);
-    name = &ext_p->name[u + 1];
-    /* find the extension definition there */
-    for (ext = NULL, u = 0; u < LY_ARRAY_SIZE(mod->parsed->extensions); ++u) {
-        if (!strcmp(name, mod->parsed->extensions[u].name)) {
-            edef = &mod->parsed->extensions[u];
-            break;
-        }
-    }
-    LY_CHECK_ERR_RET(!edef, LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-                                   "Extension definition of extension instance \"%s\" not found.", ext_p->name),
-                     LY_EVALID);
-    /* TODO plugins */
-
-    return LY_SUCCESS;
-}
-
-static LY_ERR
-lys_compile_iffeature(struct lysc_ctx *ctx, const char **value, int UNUSED(options), struct lysc_iffeature *iff)
-{
-    const char *c = *value;
-    int r, rc = EXIT_FAILURE;
-    int i, j, last_not, checkversion = 0;
-    unsigned int f_size = 0, expr_size = 0, f_exp = 1;
-    uint8_t op;
-    struct iff_stack stack = {0, 0, NULL};
-    struct lysc_feature *f;
-
-    assert(c);
-
-    /* pre-parse the expression to get sizes for arrays, also do some syntax checks of the expression */
-    for (i = j = last_not = 0; c[i]; i++) {
-        if (c[i] == '(') {
-            j++;
-            checkversion = 1;
-            continue;
-        } else if (c[i] == ')') {
-            j--;
-            continue;
-        } else if (isspace(c[i])) {
-            checkversion = 1;
-            continue;
-        }
-
-        if (!strncmp(&c[i], "not", r = 3) || !strncmp(&c[i], "and", r = 3) || !strncmp(&c[i], "or", r = 2)) {
-            if (c[i + r] == '\0') {
-                LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                       "Invalid value \"%s\" of if-feature - unexpected end of expression.", *value);
-                return LY_EVALID;
-            } else if (!isspace(c[i + r])) {
-                /* feature name starting with the not/and/or */
-                last_not = 0;
-                f_size++;
-            } else if (c[i] == 'n') { /* not operation */
-                if (last_not) {
-                    /* double not */
-                    expr_size = expr_size - 2;
-                    last_not = 0;
-                } else {
-                    last_not = 1;
-                }
-            } else { /* and, or */
-                f_exp++;
-                /* not a not operation */
-                last_not = 0;
-            }
-            i += r;
-        } else {
-            f_size++;
-            last_not = 0;
-        }
-        expr_size++;
-
-        while (!isspace(c[i])) {
-            if (!c[i] || c[i] == ')') {
-                i--;
-                break;
-            }
-            i++;
-        }
-    }
-    if (j || f_exp != f_size) {
-        /* not matching count of ( and ) */
-        LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-               "Invalid value \"%s\" of if-feature - non-matching opening and closing parentheses.", *value);
-        return LY_EVALID;
-    }
-
-    if (checkversion || expr_size > 1) {
-        /* check that we have 1.1 module */
-        if (ctx->mod->compiled->version != LYS_VERSION_1_1) {
-            LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                   "Invalid value \"%s\" of if-feature - YANG 1.1 expression in YANG 1.0 module.", *value);
-            return LY_EVALID;
-        }
-    }
-
-    /* allocate the memory */
-    LY_ARRAY_CREATE_RET(ctx->ctx, iff->features, f_size, LY_EMEM);
-    iff->expr = calloc((j = (expr_size / 4) + ((expr_size % 4) ? 1 : 0)), sizeof *iff->expr);
-    stack.stack = malloc(expr_size * sizeof *stack.stack);
-    LY_CHECK_ERR_GOTO(!stack.stack || !iff->expr, LOGMEM(ctx->ctx), error);
-
-    stack.size = expr_size;
-    f_size--; expr_size--; /* used as indexes from now */
-
-    for (i--; i >= 0; i--) {
-        if (c[i] == ')') {
-            /* push it on stack */
-            iff_stack_push(&stack, LYS_IFF_RP);
-            continue;
-        } else if (c[i] == '(') {
-            /* pop from the stack into result all operators until ) */
-            while((op = iff_stack_pop(&stack)) != LYS_IFF_RP) {
-                iff_setop(iff->expr, op, expr_size--);
-            }
-            continue;
-        } else if (isspace(c[i])) {
-            continue;
-        }
-
-        /* end of operator or operand -> find beginning and get what is it */
-        j = i + 1;
-        while (i >= 0 && !isspace(c[i]) && c[i] != '(') {
-            i--;
-        }
-        i++; /* go back by one step */
-
-        if (!strncmp(&c[i], "not", 3) && isspace(c[i + 3])) {
-            if (stack.index && stack.stack[stack.index - 1] == LYS_IFF_NOT) {
-                /* double not */
-                iff_stack_pop(&stack);
-            } else {
-                /* not has the highest priority, so do not pop from the stack
-                 * as in case of AND and OR */
-                iff_stack_push(&stack, LYS_IFF_NOT);
-            }
-        } else if (!strncmp(&c[i], "and", 3) && isspace(c[i + 3])) {
-            /* as for OR - pop from the stack all operators with the same or higher
-             * priority and store them to the result, then push the AND to the stack */
-            while (stack.index && stack.stack[stack.index - 1] <= LYS_IFF_AND) {
-                op = iff_stack_pop(&stack);
-                iff_setop(iff->expr, op, expr_size--);
-            }
-            iff_stack_push(&stack, LYS_IFF_AND);
-        } else if (!strncmp(&c[i], "or", 2) && isspace(c[i + 2])) {
-            while (stack.index && stack.stack[stack.index - 1] <= LYS_IFF_OR) {
-                op = iff_stack_pop(&stack);
-                iff_setop(iff->expr, op, expr_size--);
-            }
-            iff_stack_push(&stack, LYS_IFF_OR);
-        } else {
-            /* feature name, length is j - i */
-
-            /* add it to the expression */
-            iff_setop(iff->expr, LYS_IFF_F, expr_size--);
-
-            /* now get the link to the feature definition */
-            f = lysc_feature_find(ctx->mod->compiled, &c[i], j - i);
-            LY_CHECK_ERR_GOTO(!f,
-                              LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                                     "Invalid value \"%s\" of if-feature - unable to find feature \"%.*s\".", *value, j - i, &c[i]);
-                              rc = LY_EVALID,
-                              error)
-            iff->features[f_size] = f;
-            LY_ARRAY_INCREMENT(iff->features);
-            f_size--;
-        }
-    }
-    while (stack.index) {
-        op = iff_stack_pop(&stack);
-        iff_setop(iff->expr, op, expr_size--);
-    }
-
-    if (++expr_size || ++f_size) {
-        /* not all expected operators and operands found */
-        LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-               "Invalid value \"%s\" of if-feature - processing error.", *value);
-        rc = LY_EINT;
-    } else {
-        rc = LY_SUCCESS;
-    }
-
-error:
-    /* cleanup */
-    iff_stack_clean(&stack);
-
-    return rc;
-}
-
-static LY_ERR
-lys_compile_when(struct lysc_ctx *ctx, struct lysp_when *when_p, int options, struct lysc_when *when)
-{
-    unsigned int u;
-    LY_ERR ret = LY_SUCCESS;
-
-    when->cond = lyxp_expr_parse(ctx->ctx, when_p->cond);
-    LY_CHECK_ERR_GOTO(!when->cond, ret = ly_errcode(ctx->ctx), done);
-    COMPILE_ARRAY_GOTO(ctx, when_p->exts, when->exts, options, u, lys_compile_ext, ret, done);
-
-done:
-    return ret;
-}
-
-static LY_ERR
-lys_compile_must(struct lysc_ctx *ctx, struct lysp_restr *must_p, int options, struct lysc_must *must)
-{
-    unsigned int u;
-    LY_ERR ret = LY_SUCCESS;
-
-    must->cond = lyxp_expr_parse(ctx->ctx, must_p->arg);
-    LY_CHECK_ERR_GOTO(!must->cond, ret = ly_errcode(ctx->ctx), done);
-
-    DUP_STRING(ctx->ctx, must->eapptag, must_p->eapptag);
-    DUP_STRING(ctx->ctx, must->emsg, must_p->emsg);
-    COMPILE_ARRAY_GOTO(ctx, must_p->exts, must->exts, options, u, lys_compile_ext, ret, done);
-
-done:
-    return ret;
-}
-
-static LY_ERR
-lys_compile_import(struct lysc_ctx *ctx, struct lysp_import *imp_p, int options, struct lysc_import *imp)
-{
-    unsigned int u;
-    struct lys_module *mod = NULL;
-    struct lysc_module *comp;
-    LY_ERR ret = LY_SUCCESS;
-
-    DUP_STRING(ctx->ctx, imp->prefix, imp_p->prefix);
-    COMPILE_ARRAY_GOTO(ctx, imp_p->exts, imp->exts, options, u, lys_compile_ext, ret, done);
-    imp->module = imp_p->module;
-
-    /* make sure that we have both versions (lysp_ and lysc_) of the imported module. To import groupings or
-     * typedefs, the lysp_ is needed. To augment or deviate imported module, we need the lysc_ structure */
-    if (!imp->module->parsed) {
-        comp = imp->module->compiled;
-        /* try to get filepath from the compiled version */
-        if (comp->filepath) {
-            mod = (struct lys_module*)lys_parse_path(ctx->ctx, comp->filepath,
-                                 !strcmp(&comp->filepath[strlen(comp->filepath - 4)], ".yin") ? LYS_IN_YIN : LYS_IN_YANG);
-            if (mod != imp->module) {
-                LOGERR(ctx->ctx, LY_EINT, "Filepath \"%s\" of the module \"%s\" does not match.",
-                       comp->filepath, comp->name);
-                mod = NULL;
-            }
-        }
-        if (!mod) {
-            if (lysp_load_module(ctx->ctx, comp->name, comp->revision, 0, 1, &mod)) {
-                LOGERR(ctx->ctx, LY_ENOTFOUND, "Unable to reload \"%s\" module to import it into \"%s\", source data not found.",
-                       comp->name, ctx->mod->compiled->name);
-                return LY_ENOTFOUND;
-            }
-        }
-    } else if (!imp->module->compiled) {
-        return lys_compile(imp->module, options);
-    }
-
-done:
-    return ret;
-}
-
-static LY_ERR
-lys_compile_identity(struct lysc_ctx *ctx, struct lysp_ident *ident_p, int options, struct lysc_ident *ident)
-{
-    unsigned int u;
-    LY_ERR ret = LY_SUCCESS;
-
-    DUP_STRING(ctx->ctx, ident->name, ident_p->name);
-    COMPILE_ARRAY_GOTO(ctx, ident_p->iffeatures, ident->iffeatures, options, u, lys_compile_iffeature, ret, done);
-    /* backlings (derived) can be added no sooner than when all the identities in the current module are present */
-    COMPILE_ARRAY_GOTO(ctx, ident_p->exts, ident->exts, options, u, lys_compile_ext, ret, done);
-    ident->flags = ident_p->flags;
-
-done:
-    return ret;
-}
-
-static LY_ERR
-lys_compile_identities_derived(struct lysc_ctx *ctx, struct lysp_ident *idents_p, struct lysc_ident *idents)
-{
-    unsigned int i, u, v;
-    const char *s, *name;
-    struct lysc_module *mod;
-    struct lysc_ident **dident;
-
-    for (i = 0; i < LY_ARRAY_SIZE(idents_p); ++i) {
-        if (!idents_p[i].bases) {
-            continue;
-        }
-        for (u = 0; u < LY_ARRAY_SIZE(idents_p[i].bases); ++u) {
-            s = strchr(idents_p[i].bases[u], ':');
-            if (s) {
-                /* prefixed identity */
-                name = &s[1];
-                mod = lysc_module_find_prefix(ctx->mod->compiled, idents_p[i].bases[u], s - idents_p[i].bases[u]);
-            } else {
-                name = idents_p[i].bases[u];
-                mod = ctx->mod->compiled;
-            }
-            LY_CHECK_ERR_RET(!mod, LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                                          "Invalid prefix used for base (%s) of identity \"%s\".", idents_p[i].bases[u], idents[i].name),
-                             LY_EVALID);
-            if (mod->identities) {
-                for (v = 0; v < LY_ARRAY_SIZE(mod->identities); ++v) {
-                    if (!strcmp(name, mod->identities[v].name)) {
-                        /* we have match! store the backlink */
-                        LY_ARRAY_NEW_RET(ctx->ctx, mod->identities[v].derived, dident, LY_EMEM);
-                        *dident = &idents[i];
-                        break;
-                    }
-                }
-            }
-            LY_CHECK_ERR_RET(!dident, LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                                             "Unable to find base (%s) of identity \"%s\".", idents_p[i].bases[u], idents[i].name),
-                             LY_EVALID);
-        }
-    }
-    return LY_SUCCESS;
-}
-
-static LY_ERR
-lys_compile_feature(struct lysc_ctx *ctx, struct lysp_feature *feature_p, int options, struct lysc_feature *feature)
-{
-    unsigned int u, v;
-    LY_ERR ret = LY_SUCCESS;
-    struct lysc_feature **df;
-
-    DUP_STRING(ctx->ctx, feature->name, feature_p->name);
-    feature->flags = feature_p->flags;
-
-    COMPILE_ARRAY_GOTO(ctx, feature_p->exts, feature->exts, options, u, lys_compile_ext, ret, done);
-    COMPILE_ARRAY_GOTO(ctx, feature_p->iffeatures, feature->iffeatures, options, u, lys_compile_iffeature, ret, done);
-    if (feature->iffeatures) {
-        for (u = 0; u < LY_ARRAY_SIZE(feature->iffeatures); ++u) {
-            if (feature->iffeatures[u].features) {
-                for (v = 0; v < LY_ARRAY_SIZE(feature->iffeatures[u].features); ++v) {
-                    /* add itself into the dependants list */
-                    LY_ARRAY_NEW_RET(ctx->ctx, feature->iffeatures[u].features[v]->depfeatures, df, LY_EMEM);
-                    *df = feature;
-                }
-                /* TODO check for circular dependency */
-            }
-        }
-    }
-done:
-    return ret;
-}
-
-static LY_ERR
-range_part_check_value_syntax(struct lysc_ctx *ctx, LY_DATA_TYPE basetype, const char *value, size_t *len, char **valcopy)
-{
-    size_t fraction = 0;
-    *len = 0;
-
-    assert(value);
-    /* parse value */
-    if (!isdigit(value[*len]) && (value[*len] != '-') && (value[*len] != '+')) {
-        return LY_EVALID;
-    }
-
-    if ((value[*len] == '-') || (value[*len] == '+')) {
-        ++(*len);
-    }
-
-    while (isdigit(value[*len])) {
-        ++(*len);
-    }
-
-    if ((basetype != LY_TYPE_DEC64) || (value[*len] != '.') || !isdigit(value[*len + 1])) {
-        *valcopy = strndup(value, *len);
-        return LY_SUCCESS;
-    }
-    fraction = *len;
-
-    ++(*len);
-    while (isdigit(value[*len])) {
-        ++(*len);
-    }
-
-    if (fraction) {
-        *valcopy = malloc(((*len) - 1) * sizeof **valcopy);
-        LY_CHECK_ERR_RET(!(*valcopy), LOGMEM(ctx->ctx), LY_EMEM);
-
-        *valcopy[(*len) - 1] = '\0';
-        memcpy(&(*valcopy)[0], &value[0], fraction);
-        memcpy(&(*valcopy)[fraction], &value[fraction + 1], (*len) - 1 - (fraction + 1));
-    }
-    return LY_SUCCESS;
-}
-
-static LY_ERR
-range_part_check_ascendance(int unsigned_value, int64_t value, int64_t prev_value)
-{
-    if (unsigned_value) {
-        if ((uint64_t)prev_value >= (uint64_t)value) {
-            return LY_EEXIST;
-        }
-    } else {
-        if (prev_value >= value) {
-            return LY_EEXIST;
-        }
-    }
-    return LY_SUCCESS;
-}
-
-static LY_ERR
-range_part_minmax(struct lysc_ctx *ctx, struct lysc_range_part *part, int max, int64_t prev, LY_DATA_TYPE basetype, int first, int length_restr,
-                  const char **value)
-{
-    LY_ERR ret = LY_SUCCESS;
-    char *valcopy = NULL;
-    size_t len;
-
-    if (value) {
-        ret = range_part_check_value_syntax(ctx, basetype, *value, &len, &valcopy);
-        LY_CHECK_GOTO(ret, error);
-    }
-
-    switch (basetype) {
-    case LY_TYPE_BINARY: /* length */
-        if (valcopy) {
-            ret = ly_parse_uint(valcopy, UINT64_C(18446744073709551615), 10, max ? &part->max_u64 : &part->min_u64);
-        } else if (max) {
-            part->max_u64 = UINT64_C(18446744073709551615);
-        } else {
-            part->min_u64 = UINT64_C(0);
-        }
-        if (!first) {
-            ret = range_part_check_ascendance(1, max ? part->max_64 : part->min_64, prev);
-        }
-        break;
-    case LY_TYPE_DEC64: /* range */
-        if (valcopy) {
-            ret = ly_parse_int(valcopy, INT64_C(-9223372036854775807) - INT64_C(1), INT64_C(9223372036854775807), 10,
-                               max ? &part->max_64 : &part->min_64);
-        } else if (max) {
-            part->max_64 = INT64_C(9223372036854775807);
-        } else {
-            part->min_64 = INT64_C(-9223372036854775807) - INT64_C(1);
-        }
-        if (!first) {
-            ret = range_part_check_ascendance(0, max ? part->max_64 : part->min_64, prev);
-        }
-        break;
-    case LY_TYPE_INT8: /* range */
-        if (valcopy) {
-            ret = ly_parse_int(valcopy, INT64_C(-128), INT64_C(127), 10, max ? &part->max_64 : &part->min_64);
-        } else if (max) {
-            part->max_64 = INT64_C(127);
-        } else {
-            part->min_64 = INT64_C(-128);
-        }
-        if (!first) {
-            ret = range_part_check_ascendance(0, max ? part->max_64 : part->min_64, prev);
-        }
-        break;
-    case LY_TYPE_INT16: /* range */
-        if (valcopy) {
-            ret = ly_parse_int(valcopy, INT64_C(-32768), INT64_C(32767), 10, max ? &part->max_64 : &part->min_64);
-        } else if (max) {
-            part->max_64 = INT64_C(32767);
-        } else {
-            part->min_64 = INT64_C(-32768);
-        }
-        if (!first) {
-            ret = range_part_check_ascendance(0, max ? part->max_64 : part->min_64, prev);
-        }
-        break;
-    case LY_TYPE_INT32: /* range */
-        if (valcopy) {
-            ret = ly_parse_int(valcopy, INT64_C(-2147483648), INT64_C(2147483647), 10, max ? &part->max_64 : &part->min_64);
-        } else if (max) {
-            part->max_64 = INT64_C(2147483647);
-        } else {
-            part->min_64 = INT64_C(-2147483648);
-        }
-        if (!first) {
-            ret = range_part_check_ascendance(0, max ? part->max_64 : part->min_64, prev);
-        }
-        break;
-    case LY_TYPE_INT64: /* range */
-        if (valcopy) {
-            ret = ly_parse_int(valcopy, INT64_C(-9223372036854775807) - INT64_C(1), INT64_C(9223372036854775807), 10,
-                               max ? &part->max_64 : &part->min_64);
-        } else if (max) {
-            part->max_64 = INT64_C(9223372036854775807);
-        } else {
-            part->min_64 = INT64_C(-9223372036854775807) - INT64_C(1);
-        }
-        if (!first) {
-            ret = range_part_check_ascendance(0, max ? part->max_64 : part->min_64, prev);
-        }
-        break;
-    case LY_TYPE_UINT8: /* range */
-        if (valcopy) {
-            ret = ly_parse_uint(valcopy, UINT64_C(255), 10, max ? &part->max_u64 : &part->min_u64);
-        } else if (max) {
-            part->max_u64 = UINT64_C(255);
-        } else {
-            part->min_u64 = UINT64_C(0);
-        }
-        if (!first) {
-            ret = range_part_check_ascendance(1, max ? part->max_64 : part->min_64, prev);
-        }
-        break;
-    case LY_TYPE_UINT16: /* range */
-        if (valcopy) {
-            ret = ly_parse_uint(valcopy, UINT64_C(65535), 10, max ? &part->max_u64 : &part->min_u64);
-        } else if (max) {
-            part->max_u64 = UINT64_C(65535);
-        } else {
-            part->min_u64 = UINT64_C(0);
-        }
-        if (!first) {
-            ret = range_part_check_ascendance(1, max ? part->max_64 : part->min_64, prev);
-        }
-        break;
-    case LY_TYPE_UINT32: /* range */
-        if (valcopy) {
-            ret = ly_parse_uint(valcopy, UINT64_C(4294967295), 10, max ? &part->max_u64 : &part->min_u64);
-        } else if (max) {
-            part->max_u64 = UINT64_C(4294967295);
-        } else {
-            part->min_u64 = UINT64_C(0);
-        }
-        if (!first) {
-            ret = range_part_check_ascendance(1, max ? part->max_64 : part->min_64, prev);
-        }
-        break;
-    case LY_TYPE_UINT64: /* range */
-        if (valcopy) {
-            ret = ly_parse_uint(valcopy, UINT64_C(18446744073709551615), 10, max ? &part->max_u64 : &part->min_u64);
-        } else if (max) {
-            part->max_u64 = UINT64_C(18446744073709551615);
-        } else {
-            part->min_u64 = UINT64_C(0);
-        }
-        if (!first) {
-            ret = range_part_check_ascendance(1, max ? part->max_64 : part->min_64, prev);
-        }
-        break;
-    case LY_TYPE_STRING: /* length */
-        if (valcopy) {
-            ret = ly_parse_uint(valcopy, UINT64_C(18446744073709551615), 10, max ? &part->max_u64 : &part->min_u64);
-        } else if (max) {
-            part->max_u64 = UINT64_C(18446744073709551615);
-        } else {
-            part->min_u64 = UINT64_C(0);
-        }
-        if (!first) {
-            ret = range_part_check_ascendance(1, max ? part->max_64 : part->min_64, prev);
-        }
-        break;
-    default:
-        LOGINT(ctx->ctx);
-        ret = LY_EINT;
-    }
-
-error:
-    if (ret == LY_EDENIED) {
-        LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-               "Invalid %s restriction - value \"%s\" does not fit the type limitations.",
-               length_restr ? "length" : "range", valcopy ? valcopy : *value);
-    } else if (ret == LY_EVALID) {
-        LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-               "Invalid %s restriction - invalid value \"%s\".",
-               length_restr ? "length" : "range", valcopy ? valcopy : *value);
-    } else if (ret == LY_EEXIST) {
-        LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                       "Invalid %s restriction - values are not in ascending order (%s).",
-                       length_restr ? "length" : "range", valcopy ? valcopy : *value);
-    } else if (!ret && value) {
-        *value = *value + len;
-    }
-    free(valcopy);
-    return ret;
-}
-
-static LY_ERR
-lys_compile_type_range(struct lysc_ctx *ctx, struct lysp_restr *range_p, LY_DATA_TYPE basetype, int length_restr,
-                       struct lysc_range *base_range, struct lysc_range **range)
-{
-    LY_ERR ret = LY_EVALID;
-    const char *expr;
-    struct lysc_range_part *parts = NULL, *part;
-    int range_expected = 0, uns;
-    unsigned int parts_done = 0, u, v;
-
-    assert(range);
-    assert(range_p);
-
-    expr = range_p->arg;
-    while(1) {
-        if (isspace(*expr)) {
-            ++expr;
-        } else if (*expr == '\0') {
-            if (range_expected) {
-                LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                       "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)) {
-                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);
-                goto cleanup;
-            }
-            parts_done++;
-            break;
-        } else if (!strncmp(expr, "min", 3)) {
-            if (parts) {
-                /* min cannot be used elsewhere than in the first part */
-                LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                       "Invalid %s restriction - unexpected data before min keyword (%.*s).", length_restr ? "length" : "range",
-                       expr - range_p->arg, range_p->arg);
-                goto cleanup;
-            }
-            expr += 3;
-
-            LY_ARRAY_NEW_GOTO(ctx->ctx, parts, part, ret, cleanup);
-            LY_CHECK_GOTO(range_part_minmax(ctx, part, 0, 0, basetype, 1, length_restr, NULL), cleanup);
-            part->max_64 = part->min_64;
-        } else if (*expr == '|') {
-            if (!parts || range_expected) {
-                LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                       "Invalid %s restriction - unexpected beginning of the expression (%s).", length_restr ? "length" : "range", expr);
-                goto cleanup;
-            }
-            expr++;
-            parts_done++;
-            /* process next part of the expression */
-        } else if (!strncmp(expr, "..", 2)) {
-            expr += 2;
-            while (isspace(*expr)) {
-                expr++;
-            }
-            if (!parts || LY_ARRAY_SIZE(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;
-            }
-            /* continue expecting the upper boundary */
-            range_expected = 1;
-        } else if (isdigit(*expr) || (*expr == '-') || (*expr == '+')) {
-            /* number */
-            if (range_expected) {
-                part = &parts[LY_ARRAY_SIZE(parts) - 1];
-                LY_CHECK_GOTO(range_part_minmax(ctx, part, 1, part->min_64, basetype, 0, length_restr, &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,
-                                                basetype, parts_done ? 0 : 1, length_restr, &expr), cleanup);
-                part->max_64 = part->min_64;
-            }
-
-            /* continue with possible another expression part */
-        } else if (!strncmp(expr, "max", 3)) {
-            expr += 3;
-            while (isspace(*expr)) {
-                expr++;
-            }
-            if (*expr != '\0') {
-                LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG, "Invalid %s restriction - unexpected data after max keyword (%s).",
-                       length_restr ? "length" : "range", expr);
-                goto cleanup;
-            }
-            if (range_expected) {
-                part = &parts[LY_ARRAY_SIZE(parts) - 1];
-                LY_CHECK_GOTO(range_part_minmax(ctx, part, 1, part->min_64, basetype, 0, length_restr, 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,
-                                                basetype, parts_done ? 0 : 1, length_restr, NULL), cleanup);
-                part->min_64 = part->max_64;
-            }
-        } else {
-            LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG, "Invalid %s restriction - unexpected data (%s).",
-                   length_restr ? "length" : "range", expr);
-            goto cleanup;
-        }
-    }
-
-    /* check with the previous range/length restriction */
-    if (base_range) {
-        switch (basetype) {
-        case LY_TYPE_BINARY:
-        case LY_TYPE_UINT8:
-        case LY_TYPE_UINT16:
-        case LY_TYPE_UINT32:
-        case LY_TYPE_UINT64:
-        case LY_TYPE_STRING:
-            uns = 1;
-            break;
-        case LY_TYPE_DEC64:
-        case LY_TYPE_INT8:
-        case LY_TYPE_INT16:
-        case LY_TYPE_INT32:
-        case LY_TYPE_INT64:
-            uns = 0;
-            break;
-        default:
-            LOGINT(ctx->ctx);
-            ret = LY_EINT;
-            goto cleanup;
-        }
-        for (u = v = 0; u < parts_done && v < LY_ARRAY_SIZE(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;
-            }
-            /* current lower bound is not lower than the base */
-            if (base_range->parts[v].min_64 == base_range->parts[v].max_64) {
-                /* base has single value */
-                if (base_range->parts[v].min_64 == parts[u].min_64) {
-                    /* both lower bounds are the same */
-                    if (parts[u].min_64 != parts[u].max_64) {
-                        /* current continues with a range */
-                        goto baseerror;
-                    } else {
-                        /* equal single values, move both forward */
-                        ++v;
-                        continue;
-                    }
-                } else {
-                    /* base is single value lower than current range, so the
-                     * value from base range is removed in the current,
-                     * move only base and repeat checking */
-                    ++v;
-                    --u;
-                    continue;
-                }
-            } else {
-                /* base is the range */
-                if (parts[u].min_64 == parts[u].max_64) {
-                    /* current is a single value */
-                    if ((uns && parts[u].max_u64 > base_range->parts[v].max_u64) || (!uns && parts[u].max_64 > base_range->parts[v].max_64)) {
-                        /* current is behind the base range, so base range is omitted,
-                         * move the base and keep the current for further check */
-                        ++v;
-                        --u;
-                    } /* else it is within the base range, so move the current, but keep the base */
-                    continue;
-                } else {
-                    /* both are ranges - check the higher bound, the lower was already checked */
-                    if ((uns && parts[u].max_u64 > base_range->parts[v].max_u64) || (!uns && parts[u].max_64 > base_range->parts[v].max_64)) {
-                        /* higher bound is higher than the current higher bound */
-                        if ((uns && parts[u].min_u64 > base_range->parts[v].max_u64) || (!uns && parts[u].min_64 > base_range->parts[v].max_64)) {
-                            /* but the current lower bound is also higher, so the base range is omitted,
-                             * continue with the same current, but move the base */
-                            --u;
-                            ++v;
-                            continue;
-                        }
-                        /* current range starts within the base range but end behind it */
-                        goto baseerror;
-                    } else {
-                        /* current range is smaller than the base,
-                         * move current, but stay with the base */
-                        continue;
-                    }
-                }
-            }
-        }
-        if (u != parts_done) {
-baseerror:
-            LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                   "Invalid %s restriction - the derived restriction (%s) is not equally or more limiting.",
-                   length_restr ? "length" : "range", range_p->arg);
-            goto cleanup;
-        }
-    }
-
-    if (!(*range)) {
-        *range = calloc(1, sizeof **range);
-        LY_CHECK_ERR_RET(!(*range), LOGMEM(ctx->ctx), LY_EMEM);
-    }
-
-    if (range_p->eapptag) {
-        lydict_remove(ctx->ctx, (*range)->eapptag);
-        (*range)->eapptag = lydict_insert(ctx->ctx, range_p->eapptag, 0);
-    }
-    if (range_p->emsg) {
-        lydict_remove(ctx->ctx, (*range)->emsg);
-        (*range)->emsg = lydict_insert(ctx->ctx, range_p->emsg, 0);
-    }
-    /* extensions are taken only from the last range by the caller */
-
-    (*range)->parts = parts;
-    parts = NULL;
-    ret = LY_SUCCESS;
-cleanup:
-    /* TODO clean up */
-    LY_ARRAY_FREE(parts);
-
-    return ret;
-}
-
-/**
- * @brief Checks pattern syntax.
- *
- * @param[in] pattern Pattern to check.
- * @param[out] pcre_precomp Precompiled PCRE pattern. Can be NULL.
- * @return EXIT_SUCCESS on success, EXIT_FAILURE otherwise.
- */
-static LY_ERR
-lys_compile_type_pattern_check(struct lysc_ctx *ctx, const char *pattern, pcre **pcre_precomp)
-{
-    int idx, idx2, start, end, err_offset, count;
-    char *perl_regex, *ptr;
-    const char *err_msg, *orig_ptr;
-    pcre *precomp;
-#define URANGE_LEN 19
-    char *ublock2urange[][2] = {
-        {"BasicLatin", "[\\x{0000}-\\x{007F}]"},
-        {"Latin-1Supplement", "[\\x{0080}-\\x{00FF}]"},
-        {"LatinExtended-A", "[\\x{0100}-\\x{017F}]"},
-        {"LatinExtended-B", "[\\x{0180}-\\x{024F}]"},
-        {"IPAExtensions", "[\\x{0250}-\\x{02AF}]"},
-        {"SpacingModifierLetters", "[\\x{02B0}-\\x{02FF}]"},
-        {"CombiningDiacriticalMarks", "[\\x{0300}-\\x{036F}]"},
-        {"Greek", "[\\x{0370}-\\x{03FF}]"},
-        {"Cyrillic", "[\\x{0400}-\\x{04FF}]"},
-        {"Armenian", "[\\x{0530}-\\x{058F}]"},
-        {"Hebrew", "[\\x{0590}-\\x{05FF}]"},
-        {"Arabic", "[\\x{0600}-\\x{06FF}]"},
-        {"Syriac", "[\\x{0700}-\\x{074F}]"},
-        {"Thaana", "[\\x{0780}-\\x{07BF}]"},
-        {"Devanagari", "[\\x{0900}-\\x{097F}]"},
-        {"Bengali", "[\\x{0980}-\\x{09FF}]"},
-        {"Gurmukhi", "[\\x{0A00}-\\x{0A7F}]"},
-        {"Gujarati", "[\\x{0A80}-\\x{0AFF}]"},
-        {"Oriya", "[\\x{0B00}-\\x{0B7F}]"},
-        {"Tamil", "[\\x{0B80}-\\x{0BFF}]"},
-        {"Telugu", "[\\x{0C00}-\\x{0C7F}]"},
-        {"Kannada", "[\\x{0C80}-\\x{0CFF}]"},
-        {"Malayalam", "[\\x{0D00}-\\x{0D7F}]"},
-        {"Sinhala", "[\\x{0D80}-\\x{0DFF}]"},
-        {"Thai", "[\\x{0E00}-\\x{0E7F}]"},
-        {"Lao", "[\\x{0E80}-\\x{0EFF}]"},
-        {"Tibetan", "[\\x{0F00}-\\x{0FFF}]"},
-        {"Myanmar", "[\\x{1000}-\\x{109F}]"},
-        {"Georgian", "[\\x{10A0}-\\x{10FF}]"},
-        {"HangulJamo", "[\\x{1100}-\\x{11FF}]"},
-        {"Ethiopic", "[\\x{1200}-\\x{137F}]"},
-        {"Cherokee", "[\\x{13A0}-\\x{13FF}]"},
-        {"UnifiedCanadianAboriginalSyllabics", "[\\x{1400}-\\x{167F}]"},
-        {"Ogham", "[\\x{1680}-\\x{169F}]"},
-        {"Runic", "[\\x{16A0}-\\x{16FF}]"},
-        {"Khmer", "[\\x{1780}-\\x{17FF}]"},
-        {"Mongolian", "[\\x{1800}-\\x{18AF}]"},
-        {"LatinExtendedAdditional", "[\\x{1E00}-\\x{1EFF}]"},
-        {"GreekExtended", "[\\x{1F00}-\\x{1FFF}]"},
-        {"GeneralPunctuation", "[\\x{2000}-\\x{206F}]"},
-        {"SuperscriptsandSubscripts", "[\\x{2070}-\\x{209F}]"},
-        {"CurrencySymbols", "[\\x{20A0}-\\x{20CF}]"},
-        {"CombiningMarksforSymbols", "[\\x{20D0}-\\x{20FF}]"},
-        {"LetterlikeSymbols", "[\\x{2100}-\\x{214F}]"},
-        {"NumberForms", "[\\x{2150}-\\x{218F}]"},
-        {"Arrows", "[\\x{2190}-\\x{21FF}]"},
-        {"MathematicalOperators", "[\\x{2200}-\\x{22FF}]"},
-        {"MiscellaneousTechnical", "[\\x{2300}-\\x{23FF}]"},
-        {"ControlPictures", "[\\x{2400}-\\x{243F}]"},
-        {"OpticalCharacterRecognition", "[\\x{2440}-\\x{245F}]"},
-        {"EnclosedAlphanumerics", "[\\x{2460}-\\x{24FF}]"},
-        {"BoxDrawing", "[\\x{2500}-\\x{257F}]"},
-        {"BlockElements", "[\\x{2580}-\\x{259F}]"},
-        {"GeometricShapes", "[\\x{25A0}-\\x{25FF}]"},
-        {"MiscellaneousSymbols", "[\\x{2600}-\\x{26FF}]"},
-        {"Dingbats", "[\\x{2700}-\\x{27BF}]"},
-        {"BraillePatterns", "[\\x{2800}-\\x{28FF}]"},
-        {"CJKRadicalsSupplement", "[\\x{2E80}-\\x{2EFF}]"},
-        {"KangxiRadicals", "[\\x{2F00}-\\x{2FDF}]"},
-        {"IdeographicDescriptionCharacters", "[\\x{2FF0}-\\x{2FFF}]"},
-        {"CJKSymbolsandPunctuation", "[\\x{3000}-\\x{303F}]"},
-        {"Hiragana", "[\\x{3040}-\\x{309F}]"},
-        {"Katakana", "[\\x{30A0}-\\x{30FF}]"},
-        {"Bopomofo", "[\\x{3100}-\\x{312F}]"},
-        {"HangulCompatibilityJamo", "[\\x{3130}-\\x{318F}]"},
-        {"Kanbun", "[\\x{3190}-\\x{319F}]"},
-        {"BopomofoExtended", "[\\x{31A0}-\\x{31BF}]"},
-        {"EnclosedCJKLettersandMonths", "[\\x{3200}-\\x{32FF}]"},
-        {"CJKCompatibility", "[\\x{3300}-\\x{33FF}]"},
-        {"CJKUnifiedIdeographsExtensionA", "[\\x{3400}-\\x{4DB5}]"},
-        {"CJKUnifiedIdeographs", "[\\x{4E00}-\\x{9FFF}]"},
-        {"YiSyllables", "[\\x{A000}-\\x{A48F}]"},
-        {"YiRadicals", "[\\x{A490}-\\x{A4CF}]"},
-        {"HangulSyllables", "[\\x{AC00}-\\x{D7A3}]"},
-        {"PrivateUse", "[\\x{E000}-\\x{F8FF}]"},
-        {"CJKCompatibilityIdeographs", "[\\x{F900}-\\x{FAFF}]"},
-        {"AlphabeticPresentationForms", "[\\x{FB00}-\\x{FB4F}]"},
-        {"ArabicPresentationForms-A", "[\\x{FB50}-\\x{FDFF}]"},
-        {"CombiningHalfMarks", "[\\x{FE20}-\\x{FE2F}]"},
-        {"CJKCompatibilityForms", "[\\x{FE30}-\\x{FE4F}]"},
-        {"SmallFormVariants", "[\\x{FE50}-\\x{FE6F}]"},
-        {"ArabicPresentationForms-B", "[\\x{FE70}-\\x{FEFE}]"},
-        {"HalfwidthandFullwidthForms", "[\\x{FF00}-\\x{FFEF}]"},
-        {NULL, NULL}
-    };
-
-    /* adjust the expression to a Perl equivalent
-     * http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#regexs */
-
-    /* we need to replace all "$" with "\$", count them now */
-    for (count = 0, ptr = strpbrk(pattern, "^$"); ptr; ++count, ptr = strpbrk(ptr + 1, "^$"));
-
-    perl_regex = malloc((strlen(pattern) + 4 + count) * sizeof(char));
-    LY_CHECK_ERR_RET(!perl_regex, LOGMEM(ctx->ctx), LY_EMEM);
-    perl_regex[0] = '\0';
-
-    ptr = perl_regex;
-
-    if (strncmp(pattern + strlen(pattern) - 2, ".*", 2)) {
-        /* we will add line-end anchoring */
-        ptr[0] = '(';
-        ++ptr;
-    }
-
-    for (orig_ptr = pattern; orig_ptr[0]; ++orig_ptr) {
-        if (orig_ptr[0] == '$') {
-            ptr += sprintf(ptr, "\\$");
-        } else if (orig_ptr[0] == '^') {
-            ptr += sprintf(ptr, "\\^");
-        } else {
-            ptr[0] = orig_ptr[0];
-            ++ptr;
-        }
-    }
-
-    if (strncmp(pattern + strlen(pattern) - 2, ".*", 2)) {
-        ptr += sprintf(ptr, ")$");
-    } else {
-        ptr[0] = '\0';
-        ++ptr;
-    }
-
-    /* substitute Unicode Character Blocks with exact Character Ranges */
-    while ((ptr = strstr(perl_regex, "\\p{Is"))) {
-        start = ptr - perl_regex;
-
-        ptr = strchr(ptr, '}');
-        if (!ptr) {
-            LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LY_VCODE_INREGEXP,
-                   pattern, perl_regex + start + 2, "unterminated character property");
-            free(perl_regex);
-            return LY_EVALID;
-        }
-        end = (ptr - perl_regex) + 1;
-
-        /* need more space */
-        if (end - start < URANGE_LEN) {
-            perl_regex = ly_realloc(perl_regex, strlen(perl_regex) + (URANGE_LEN - (end - start)) + 1);
-            LY_CHECK_ERR_RET(!perl_regex, LOGMEM(ctx->ctx); free(perl_regex), LY_EMEM);
-        }
-
-        /* find our range */
-        for (idx = 0; ublock2urange[idx][0]; ++idx) {
-            if (!strncmp(perl_regex + start + 5, ublock2urange[idx][0], strlen(ublock2urange[idx][0]))) {
-                break;
-            }
-        }
-        if (!ublock2urange[idx][0]) {
-            LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LY_VCODE_INREGEXP,
-                   pattern, perl_regex + start + 5, "unknown block name");
-            free(perl_regex);
-            return LY_EVALID;
-        }
-
-        /* make the space in the string and replace the block (but we cannot include brackets if it was already enclosed in them) */
-        for (idx2 = 0, count = 0; idx2 < start; ++idx2) {
-            if ((perl_regex[idx2] == '[') && (!idx2 || (perl_regex[idx2 - 1] != '\\'))) {
-                ++count;
-            }
-            if ((perl_regex[idx2] == ']') && (!idx2 || (perl_regex[idx2 - 1] != '\\'))) {
-                --count;
-            }
-        }
-        if (count) {
-            /* skip brackets */
-            memmove(perl_regex + start + (URANGE_LEN - 2), perl_regex + end, strlen(perl_regex + end) + 1);
-            memcpy(perl_regex + start, ublock2urange[idx][1] + 1, URANGE_LEN - 2);
-        } else {
-            memmove(perl_regex + start + URANGE_LEN, perl_regex + end, strlen(perl_regex + end) + 1);
-            memcpy(perl_regex + start, ublock2urange[idx][1], URANGE_LEN);
-        }
-    }
-
-    /* must return 0, already checked during parsing */
-    precomp = pcre_compile(perl_regex, PCRE_UTF8 | PCRE_ANCHORED | PCRE_DOLLAR_ENDONLY | PCRE_NO_AUTO_CAPTURE,
-                           &err_msg, &err_offset, NULL);
-    if (!precomp) {
-        LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LY_VCODE_INREGEXP, pattern, perl_regex + err_offset, err_msg);
-        free(perl_regex);
-        return LY_EVALID;
-    }
-    free(perl_regex);
-
-    if (pcre_precomp) {
-        *pcre_precomp = precomp;
-    } else {
-        free(precomp);
-    }
-
-    return LY_SUCCESS;
-
-#undef URANGE_LEN
-}
-
-static LY_ERR
-lys_compile_type_patterns(struct lysc_ctx *ctx, struct lysp_restr *patterns_p, int options,
-                          struct lysc_pattern **base_patterns, struct lysc_pattern ***patterns)
-{
-    struct lysc_pattern **result = NULL, **pattern;
-    unsigned int u, v;
-    const char *err_msg;
-    LY_ERR ret;
-
-    /* first, copy the patterns from the base type */
-    if (base_patterns) {
-        result = lysc_patterns_dup(ctx->ctx, base_patterns);
-        LY_CHECK_ERR_RET(!result, LOGMEM(ctx->ctx), LY_EMEM);
-    }
-
-    LY_ARRAY_FOR(patterns_p, u) {
-        LY_ARRAY_NEW_GOTO(ctx->ctx, result, pattern, ret, cleanup);
-        *pattern = calloc(1, sizeof **pattern);
-        ++(*pattern)->refcount;
-
-        ret = lys_compile_type_pattern_check(ctx, &patterns_p[u].arg[1], &(*pattern)->expr);
-        LY_CHECK_GOTO(ret, cleanup);
-        (*pattern)->expr_extra = pcre_study((*pattern)->expr, 0, &err_msg);
-        if (err_msg) {
-            LOGWRN(ctx->ctx, "Studying pattern \"%s\" failed (%s).", pattern, err_msg);
-        }
-
-        if (patterns_p[u].arg[0] == 0x15) {
-            (*pattern)->inverted = 1;
-        }
-        DUP_STRING(ctx->ctx, (*pattern)->eapptag, patterns_p[u].eapptag);
-        DUP_STRING(ctx->ctx, (*pattern)->emsg, patterns_p[u].emsg);
-        COMPILE_ARRAY_GOTO(ctx, patterns_p[u].exts, (*pattern)->exts,
-                           options, v, lys_compile_ext, ret, cleanup);
-    }
-
-    (*patterns) = result;
-    result = NULL;
-    ret = LY_SUCCESS;
-
-cleanup:
-    FREE_ARRAY(ctx->ctx, result, lysc_pattern_free);
-
-    return ret;
-}
-
-static uint16_t type_substmt_map[LY_DATA_TYPE_COUNT] = {
-    0 /* LY_TYPE_UNKNOWN */,
-    LYS_SET_LENGTH /* LY_TYPE_BINARY */,
-    LYS_SET_BIT /* LY_TYPE_BITS */,
-    0 /* LY_TYPE_BOOL */,
-    LYS_SET_FRDIGITS | LYS_SET_RANGE /* LY_TYPE_DEC64 */,
-    0 /* LY_TYPE_EMPTY */,
-    LYS_SET_ENUM /* LY_TYPE_ENUM */,
-    LYS_SET_BASE /* LY_TYPE_IDENT */,
-    LYS_SET_REQINST /* LY_TYPE_INST */,
-    LYS_SET_REQINST | LYS_SET_PATH /* LY_TYPE_LEAFREF */,
-    LYS_SET_LENGTH | LYS_SET_PATTERN /* LY_TYPE_STRING */,
-    LYS_SET_TYPE /* LY_TYPE_UNION */,
-    LYS_SET_RANGE /* LY_TYPE_INT8 */,
-    LYS_SET_RANGE /* LY_TYPE_UINT8 */,
-    LYS_SET_RANGE /* LY_TYPE_INT16 */,
-    LYS_SET_RANGE /* LY_TYPE_UINT16 */,
-    LYS_SET_RANGE /* LY_TYPE_INT32 */,
-    LYS_SET_RANGE /* LY_TYPE_UINT32 */,
-    LYS_SET_RANGE /* LY_TYPE_INT64 */,
-    LYS_SET_RANGE /* LY_TYPE_UINT64 */
-};
-
-static LY_ERR
-lys_compile_type_enums(struct lysc_ctx *ctx, struct lysp_type_enum *enums_p, LY_DATA_TYPE basetype, int options,
-                       struct lysc_type_enum_item *base_enums, struct lysc_type_enum_item **enums)
-{
-    LY_ERR ret = LY_SUCCESS;
-    unsigned int u, v, match;
-    int32_t value = 0;
-    uint32_t position = 0;
-    struct lysc_type_enum_item *e, storage;
-
-    if (base_enums && ctx->mod->compiled->version < 2) {
-        LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG, "%s type can be subtyped only in YANG 1.1 modules.",
-               basetype == LY_TYPE_ENUM ? "Enumeration" : "Bits");
-        return LY_EVALID;
-    }
-
-    LY_ARRAY_FOR(enums_p, u) {
-        LY_ARRAY_NEW_RET(ctx->ctx, *enums, e, LY_EMEM);
-        DUP_STRING(ctx->ctx, e->name, enums_p[u].name);
-        if (base_enums) {
-            /* check the enum/bit presence in the base type - the set of enums/bits in the derived type must be a subset */
-            LY_ARRAY_FOR(base_enums, v) {
-                if (!strcmp(e->name, base_enums[v].name)) {
-                    break;
-                }
-            }
-            if (v == LY_ARRAY_SIZE(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);
-                return LY_EVALID;
-            }
-            match = v;
-        }
-
-        if (basetype == LY_TYPE_ENUM) {
-            if (enums_p[u].flags & LYS_SET_VALUE) {
-                e->value = (int32_t)enums_p[u].value;
-                if (!u || e->value >= value) {
-                    value = e->value + 1;
-                }
-                /* check collision with other values */
-                for (v = 0; v < LY_ARRAY_SIZE(*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\".",
-                               e->value, e->name, (*enums)[v].name);
-                        return LY_EVALID;
-                    }
-                }
-            } else if (base_enums) {
-                /* inherit the assigned value */
-                e->value = base_enums[match].value;
-                if (!u || e->value >= value) {
-                    value = e->value + 1;
-                }
-            } else {
-                /* assign value automatically */
-                if (u && value == INT32_MIN) {
-                    /* counter overflow */
-                    LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                           "Invalid enumeration - it is not possible to auto-assign enum value for "
-                           "\"%s\" since the highest value is already 2147483647.", e->name);
-                    return LY_EVALID;
-                }
-                e->value = value++;
-            }
-        } else { /* LY_TYPE_BITS */
-            if (enums_p[u].flags & LYS_SET_VALUE) {
-                e->value = (int32_t)enums_p[u].value;
-                if (!u || (uint32_t)e->value >= position) {
-                    position = (uint32_t)e->value + 1;
-                }
-                /* check collision with other values */
-                for (v = 0; v < LY_ARRAY_SIZE(*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\".",
-                               (uint32_t)e->value, e->name, (*enums)[v].name);
-                        return LY_EVALID;
-                    }
-                }
-            } else if (base_enums) {
-                /* inherit the assigned value */
-                e->value = base_enums[match].value;
-                if (!u || (uint32_t)e->value >= position) {
-                    position = (uint32_t)e->value + 1;
-                }
-            } else {
-                /* assign value automatically */
-                if (u && position == 0) {
-                    /* counter overflow */
-                    LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                           "Invalid bits - it is not possible to auto-assign bit position for "
-                           "\"%s\" since the highest value is already 4294967295.", e->name);
-                    return LY_EVALID;
-                }
-                e->value = position++;
-            }
-        }
-
-        if (base_enums) {
-            /* the assigned values must not change from the derived type */
-            if (e->value != base_enums[match].value) {
-                if (basetype == LY_TYPE_ENUM) {
-                    LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                       "Invalid enumeration - value of the item \"%s\" has changed from %d to %d in the derived type.",
-                       e->name, base_enums[match].value, e->value);
-                } else {
-                    LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                       "Invalid bits - position of the item \"%s\" has changed from %u to %u in the derived type.",
-                       e->name, (uint32_t)base_enums[match].value, (uint32_t)e->value);
-                }
-                return LY_EVALID;
-            }
-        }
-
-        COMPILE_ARRAY_GOTO(ctx, enums_p[u].iffeatures, e->iffeatures, options, v, lys_compile_iffeature, ret, done);
-        COMPILE_ARRAY_GOTO(ctx, enums_p[u].exts, e->exts, options, v, lys_compile_ext, ret, done);
-
-        if (basetype == LY_TYPE_BITS) {
-            /* keep bits ordered by position */
-            for (v = u; v && (*enums)[v - 1].value > e->value; --v);
-            if (v != u) {
-                memcpy(&storage, e, sizeof *e);
-                memmove(&(*enums)[v + 1], &(*enums)[v], (u - v) * sizeof **enums);
-                memcpy(&(*enums)[v], &storage, sizeof storage);
-            }
-        }
-    }
-
-done:
-    return ret;
-}
-
-static LY_ERR
-lys_compile_type(struct lysc_ctx *ctx, struct lysp_node_leaf *leaf_p, int options, struct lysc_type **type)
-{
-    LY_ERR ret = LY_SUCCESS;
-    unsigned int u;
-    struct lysp_type *type_p = &leaf_p->type;
-    struct type_context {
-        const struct lysp_tpdf *tpdf;
-        struct lysp_node *node;
-        struct lysp_module *mod;
-    } *tctx, *tctx_prev = NULL;
-    LY_DATA_TYPE basetype = LY_TYPE_UNKNOWN;
-    struct lysc_type *base = NULL;
-    struct ly_set tpdf_chain = {0};
-    struct lysc_type_bin *bin;
-    struct lysc_type_num *num;
-    struct lysc_type_str *str;
-    struct lysc_type_bits *bits;
-    struct lysc_type_enum *enumeration;
-
-    (*type) = NULL;
-
-    tctx = calloc(1, sizeof *tctx);
-    LY_CHECK_ERR_RET(!tctx, LOGMEM(ctx->ctx), LY_EMEM);
-    for (ret = lysp_type_find(type_p->name, (struct lysp_node*)leaf_p, ctx->mod->parsed,
-                             &basetype, &tctx->tpdf, &tctx->node, &tctx->mod);
-            ret == LY_SUCCESS;
-            ret = lysp_type_find(tctx_prev->tpdf->type.name, tctx_prev->node, tctx_prev->mod,
-                                         &basetype, &tctx->tpdf, &tctx->node, &tctx->mod)) {
-        if (basetype) {
-            break;
-        }
-
-        /* check status */
-        ret = lysc_check_status(ctx, leaf_p->flags, ctx->mod->parsed, leaf_p->name,
-                                tctx->tpdf->flags, tctx->mod, tctx->node ? tctx->node->name : tctx->mod->name);
-        LY_CHECK_ERR_GOTO(ret,  free(tctx), cleanup);
-
-        if (tctx->tpdf->type.compiled) {
-            /* it is not necessary to continue, the rest of the chain was already compiled */
-            basetype = tctx->tpdf->type.compiled->basetype;
-            ly_set_add(&tpdf_chain, tctx, LY_SET_OPT_USEASLIST);
-            tctx = NULL;
-            break;
-        }
-
-        /* store information for the following processing */
-        ly_set_add(&tpdf_chain, tctx, LY_SET_OPT_USEASLIST);
-
-        /* prepare next loop */
-        tctx_prev = tctx;
-        tctx = calloc(1, sizeof *tctx);
-        LY_CHECK_ERR_RET(!tctx, LOGMEM(ctx->ctx), LY_EMEM);
-    }
-    free(tctx);
-
-    /* allocate type according to the basetype */
-    switch (basetype) {
-    case LY_TYPE_BINARY:
-        *type = calloc(1, sizeof(struct lysc_type_bin));
-        bin = (struct lysc_type_bin*)(*type);
-        break;
-    case LY_TYPE_BITS:
-        *type = calloc(1, sizeof(struct lysc_type_bits));
-        bits = (struct lysc_type_bits*)(*type);
-        break;
-    case LY_TYPE_BOOL:
-    case LY_TYPE_EMPTY:
-        *type = calloc(1, sizeof(struct lysc_type));
-        break;
-    case LY_TYPE_DEC64:
-        *type = calloc(1, sizeof(struct lysc_type_dec));
-        break;
-    case LY_TYPE_ENUM:
-        *type = calloc(1, sizeof(struct lysc_type_enum));
-        enumeration = (struct lysc_type_enum*)(*type);
-        break;
-    case LY_TYPE_IDENT:
-        *type = calloc(1, sizeof(struct lysc_type_identityref));
-        break;
-    case LY_TYPE_INST:
-        *type = calloc(1, sizeof(struct lysc_type_instanceid));
-        break;
-    case LY_TYPE_LEAFREF:
-        *type = calloc(1, sizeof(struct lysc_type_leafref));
-        break;
-    case LY_TYPE_STRING:
-        *type = calloc(1, sizeof(struct lysc_type_str));
-        str = (struct lysc_type_str*)(*type);
-        break;
-    case LY_TYPE_UNION:
-        *type = calloc(1, sizeof(struct lysc_type_union));
-        break;
-    case LY_TYPE_INT8:
-    case LY_TYPE_UINT8:
-    case LY_TYPE_INT16:
-    case LY_TYPE_UINT16:
-    case LY_TYPE_INT32:
-    case LY_TYPE_UINT32:
-    case LY_TYPE_INT64:
-    case LY_TYPE_UINT64:
-        *type = calloc(1, sizeof(struct lysc_type_num));
-        num = (struct lysc_type_num*)(*type);
-        break;
-    case LY_TYPE_UNKNOWN:
-        LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
-               "Referenced type \"%s\" not found.", tctx_prev ? tctx_prev->tpdf->type.name : type_p->name);
-        ret = LY_EVALID;
-        goto cleanup;
-    }
-    LY_CHECK_ERR_GOTO(!(*type), LOGMEM(ctx->ctx), cleanup);
-    if (~type_substmt_map[basetype] & leaf_p->type.flags) {
-        LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG, "Invalid type restrictions for %s type.",
-               ly_data_type2str[basetype]);
-        free(*type);
-        (*type) = NULL;
-        ret = LY_EVALID;
-        goto cleanup;
-    }
-
-    /* get restrictions from the referred typedefs */
-    for (u = tpdf_chain.count - 1; u + 1 > 0; --u) {
-        tctx = (struct type_context*)tpdf_chain.objs[u];
-        if (~type_substmt_map[basetype] & tctx->tpdf->type.flags) {
-            LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG, "Invalid type \"%s\" restriction(s) for %s type.",
-                   tctx->tpdf->name, ly_data_type2str[basetype]);
-            ret = LY_EVALID;
-            goto cleanup;
-        } else if (tctx->tpdf->type.compiled) {
-            base = tctx->tpdf->type.compiled;
-            continue;
-        } else if ((u != tpdf_chain.count - 1) && !(tctx->tpdf->type.flags)) {
-            /* no change, just use the type information from the base */
-            base = ((struct lysp_tpdf*)tctx->tpdf)->type.compiled = ((struct type_context*)tpdf_chain.objs[u + 1])->tpdf->type.compiled;
-            ++base->refcount;
-            continue;
-        }
-
-        ++(*type)->refcount;
-        (*type)->basetype = basetype;
-        switch (basetype) {
-        case LY_TYPE_BINARY:
-            /* RFC 6020 9.8.1, 9.4.4 - length, number of octets it contains */
-            if (tctx->tpdf->type.length) {
-                ret = lys_compile_type_range(ctx, tctx->tpdf->type.length, basetype, 1,
-                                             base ? ((struct lysc_type_bin*)base)->length : NULL, &bin->length);
-                LY_CHECK_GOTO(ret, cleanup);
-            }
-
-            base = ((struct lysp_tpdf*)tctx->tpdf)->type.compiled = *type;
-            *type = calloc(1, sizeof(struct lysc_type_bin));
-            bin = (struct lysc_type_bin*)(*type);
-            break;
-        case LY_TYPE_BITS:
-            /* RFC 6020 9.6 - enum */
-            if (tctx->tpdf->type.bits) {
-                ret = lys_compile_type_enums(ctx, tctx->tpdf->type.bits, basetype, options,
-                                             base ? (struct lysc_type_enum_item*)((struct lysc_type_bits*)base)->bits : NULL,
-                                             (struct lysc_type_enum_item**)&bits->bits);
-                LY_CHECK_GOTO(ret, cleanup);
-            }
-
-            if ((u == tpdf_chain.count - 1) && !(tctx->tpdf->type.flags)) {
-                /* type derived from bits built-in type must contain at least one bit */
-                if (!bits->bits) {
-                    LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                           "Missing bit substatement for bits type \"%s\".", tctx->tpdf->name);
-                    ret = LY_EVALID;
-                    goto cleanup;
-                }
-            }
-
-            base = ((struct lysp_tpdf*)tctx->tpdf)->type.compiled = *type;
-            *type = calloc(1, sizeof(struct lysc_type_bits));
-            bits = (struct lysc_type_bits*)(*type);
-            break;
-        case LY_TYPE_STRING:
-            /* RFC 6020 9.4.4 - length */
-            if (tctx->tpdf->type.length) {
-                ret = lys_compile_type_range(ctx, tctx->tpdf->type.length, basetype, 1,
-                                             base ? ((struct lysc_type_str*)base)->length : NULL, &str->length);
-                LY_CHECK_GOTO(ret, cleanup);
-            } else if (base && ((struct lysc_type_str*)base)->length) {
-                str->length = lysc_range_dup(ctx->ctx, ((struct lysc_type_str*)base)->length);
-            }
-
-            /* RFC 6020 9.4.6 - pattern */
-            if (tctx->tpdf->type.patterns) {
-                ret = lys_compile_type_patterns(ctx, tctx->tpdf->type.patterns, options,
-                                                base ? ((struct lysc_type_str*)base)->patterns : NULL, &str->patterns);
-                LY_CHECK_GOTO(ret, cleanup);
-            } else if (base && ((struct lysc_type_str*)base)->patterns) {
-                str->patterns = lysc_patterns_dup(ctx->ctx, ((struct lysc_type_str*)base)->patterns);
-            }
-
-            base = ((struct lysp_tpdf*)tctx->tpdf)->type.compiled = *type;
-            *type = calloc(1, sizeof(struct lysc_type_str));
-            str = (struct lysc_type_str*)(*type);
-            break;
-        case LY_TYPE_ENUM:
-            /* RFC 6020 9.6 - enum */
-            if (tctx->tpdf->type.enums) {
-                ret = lys_compile_type_enums(ctx, tctx->tpdf->type.enums, basetype, options,
-                                             base ? ((struct lysc_type_enum*)base)->enums : NULL, &enumeration->enums);
-                LY_CHECK_GOTO(ret, cleanup);
-            }
-
-            if ((u == tpdf_chain.count - 1) && !(tctx->tpdf->type.flags)) {
-                /* type derived from enumerations built-in type must contain at least one enum */
-                if (!enumeration->enums) {
-                    LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                           "Missing enum substatement for enumeration type \"%s\".", tctx->tpdf->name);
-                    ret = LY_EVALID;
-                    goto cleanup;
-                }
-            }
-
-            base = ((struct lysp_tpdf*)tctx->tpdf)->type.compiled = *type;
-            *type = calloc(1, sizeof(struct lysc_type_enum));
-            enumeration = (struct lysc_type_enum*)(*type);
-            break;
-        case LY_TYPE_INT8:
-        case LY_TYPE_UINT8:
-        case LY_TYPE_INT16:
-        case LY_TYPE_UINT16:
-        case LY_TYPE_INT32:
-        case LY_TYPE_UINT32:
-        case LY_TYPE_INT64:
-        case LY_TYPE_UINT64:
-            /* RFC 6020 9.2.4 - range */
-            if (tctx->tpdf->type.range) {
-                ret = lys_compile_type_range(ctx, tctx->tpdf->type.range, basetype, 1,
-                                             base ? ((struct lysc_type_num*)base)->range : NULL, &num->range);
-                LY_CHECK_GOTO(ret, cleanup);
-            }
-
-            base = ((struct lysp_tpdf*)tctx->tpdf)->type.compiled = *type;
-            *type = calloc(1, sizeof(struct lysc_type_num));
-            num = (struct lysc_type_num*)(*type);
-            break;
-        case LY_TYPE_BOOL:
-        case LY_TYPE_EMPTY:
-        case LY_TYPE_UNKNOWN: /* just to complete switch */
-            base = ((struct lysp_tpdf*)tctx->tpdf)->type.compiled = *type;
-            *type = calloc(1, sizeof(struct lysc_type));
-            break;
-        }
-        LY_CHECK_ERR_GOTO(!(*type), LOGMEM(ctx->ctx); ret = LY_EMEM, cleanup);
-
-    }
-
-    if (leaf_p->type.flags) {
-        /* get restrictions from the node itself, finalize the type structure */
-        (*type)->basetype = basetype;
-        ++(*type)->refcount;
-        switch (basetype) {
-        case LY_TYPE_BINARY:
-            if (leaf_p->type.length) {
-                ret = lys_compile_type_range(ctx, leaf_p->type.length, basetype, 1,
-                                             base ? ((struct lysc_type_bin*)base)->length : NULL, &bin->length);
-                LY_CHECK_GOTO(ret, cleanup);
-                COMPILE_ARRAY_GOTO(ctx, leaf_p->type.length->exts, bin->length->exts,
-                                   options, u, lys_compile_ext, ret, cleanup);
-            }
-            break;
-        case LY_TYPE_BITS:
-            if (leaf_p->type.bits) {
-                ret = lys_compile_type_enums(ctx, leaf_p->type.bits, basetype, options,
-                                             base ? (struct lysc_type_enum_item*)((struct lysc_type_bits*)base)->bits : NULL,
-                                             (struct lysc_type_enum_item**)&bits->bits);
-                LY_CHECK_GOTO(ret, cleanup);
-            }
-            break;
-        case LY_TYPE_STRING:
-            if (leaf_p->type.length) {
-                ret = lys_compile_type_range(ctx, leaf_p->type.length, basetype, 1,
-                                             base ? ((struct lysc_type_str*)base)->length : NULL, &str->length);
-                LY_CHECK_GOTO(ret, cleanup);
-                COMPILE_ARRAY_GOTO(ctx, leaf_p->type.length->exts, str->length->exts,
-                                   options, u, lys_compile_ext, ret, cleanup);
-            } else if (base && ((struct lysc_type_str*)base)->length) {
-                str->length = lysc_range_dup(ctx->ctx, ((struct lysc_type_str*)base)->length);
-            }
-
-            if (leaf_p->type.patterns) {
-                ret = lys_compile_type_patterns(ctx, leaf_p->type.patterns, options,
-                                                base ? ((struct lysc_type_str*)base)->patterns : NULL, &str->patterns);
-                LY_CHECK_GOTO(ret, cleanup);
-            } else if (base && ((struct lysc_type_str*)base)->patterns) {
-                str->patterns = lysc_patterns_dup(ctx->ctx, ((struct lysc_type_str*)base)->patterns);
-            }
-            break;
-        case LY_TYPE_ENUM:
-            if (leaf_p->type.enums) {
-                ret = lys_compile_type_enums(ctx, leaf_p->type.enums, basetype, options,
-                                             base ? ((struct lysc_type_enum*)base)->enums : NULL, &enumeration->enums);
-                LY_CHECK_GOTO(ret, cleanup);
-            }
-            break;
-        case LY_TYPE_INT8:
-        case LY_TYPE_UINT8:
-        case LY_TYPE_INT16:
-        case LY_TYPE_UINT16:
-        case LY_TYPE_INT32:
-        case LY_TYPE_UINT32:
-        case LY_TYPE_INT64:
-        case LY_TYPE_UINT64:
-            if (leaf_p->type.range) {
-                ret = lys_compile_type_range(ctx, leaf_p->type.range, basetype, 0,
-                                             base ? ((struct lysc_type_num*)base)->range : NULL, &num->range);
-                LY_CHECK_GOTO(ret, cleanup);
-                COMPILE_ARRAY_GOTO(ctx, leaf_p->type.range->exts, num->range->exts,
-                                   options, u, lys_compile_ext, ret, cleanup);
-            }
-            break;
-        case LY_TYPE_BOOL:
-        case LY_TYPE_EMPTY:
-        case LY_TYPE_UNKNOWN: /* just to complete switch */
-            /* nothing to do */
-            break;
-        }
-    } else if (base) {
-        /* no specific restriction in leaf's type definition, copy from the base */
-        free(*type);
-        (*type) = base;
-        ++(*type)->refcount;
-    } else {
-        /* there are some limitations on types derived directly from built-in types */
-        if (basetype == LY_TYPE_BITS) {
-            if (!bits->bits) {
-                LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                       "Missing bit substatement for bits type.");
-                free(*type);
-                *type = NULL;
-                ret = LY_EVALID;
-                goto cleanup;
-            }
-        } else if (basetype == LY_TYPE_ENUM) {
-            if (!enumeration->enums) {
-                LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
-                       "Missing enum substatement for enumeration type.");
-                free(*type);
-                *type = NULL;
-                ret = LY_EVALID;
-                goto cleanup;
-            }
-        }
-    }
-
-    COMPILE_ARRAY_GOTO(ctx, type_p->exts, (*type)->exts, options, u, lys_compile_ext, ret, cleanup);
-
-cleanup:
-    ly_set_erase(&tpdf_chain, free);
-    return ret;
-}
-
-static LY_ERR lys_compile_node(struct lysc_ctx *ctx, struct lysp_node *node_p, int options, struct lysc_node *parent);
-
-static LY_ERR
-lys_compile_node_container(struct lysc_ctx *ctx, struct lysp_node *node_p, int options, struct lysc_node *node)
-{
-    struct lysp_node_container *cont_p = (struct lysp_node_container*)node_p;
-    struct lysc_node_container *cont = (struct lysc_node_container*)node;
-    struct lysp_node *child_p;
-    unsigned int u;
-    LY_ERR ret = LY_SUCCESS;
-
-    COMPILE_MEMBER_GOTO(ctx, cont_p->when, cont->when, options, lys_compile_when, ret, done);
-    COMPILE_ARRAY_GOTO(ctx, cont_p->iffeatures, cont->iffeatures, options, u, lys_compile_iffeature, ret, done);
-
-    LY_LIST_FOR(cont_p->child, child_p) {
-        LY_CHECK_RET(lys_compile_node(ctx, child_p, options, node));
-    }
-
-    COMPILE_ARRAY_GOTO(ctx, cont_p->musts, cont->musts, options, u, lys_compile_must, ret, done);
-    //COMPILE_ARRAY_GOTO(ctx, cont_p->actions, cont->actions, options, u, lys_compile_action, ret, done);
-    //COMPILE_ARRAY_GOTO(ctx, cont_p->notifs, cont->notifs, options, u, lys_compile_notif, ret, done);
-
-done:
-    return ret;
-}
-
-static LY_ERR
-lys_compile_node_leaf(struct lysc_ctx *ctx, struct lysp_node *node_p, int options, struct lysc_node *node)
-{
-    struct lysp_node_leaf *leaf_p = (struct lysp_node_leaf*)node_p;
-    struct lysc_node_leaf *leaf = (struct lysc_node_leaf*)node;
-    unsigned int u;
-    LY_ERR ret = LY_SUCCESS;
-
-    COMPILE_MEMBER_GOTO(ctx, leaf_p->when, leaf->when, options, lys_compile_when, ret, done);
-    COMPILE_ARRAY_GOTO(ctx, leaf_p->iffeatures, leaf->iffeatures, options, u, lys_compile_iffeature, ret, done);
-
-    COMPILE_ARRAY_GOTO(ctx, leaf_p->musts, leaf->musts, options, u, lys_compile_must, ret, done);
-    ret = lys_compile_type(ctx, leaf_p, options, &leaf->type);
-    LY_CHECK_GOTO(ret, done);
-
-    DUP_STRING(ctx->ctx, leaf->units, leaf_p->units);
-    DUP_STRING(ctx->ctx, leaf->dflt, leaf_p->dflt);
-done:
-    return ret;
-}
-
-static LY_ERR
-lys_compile_node(struct lysc_ctx *ctx, struct lysp_node *node_p, int options, struct lysc_node *parent)
-{
-    LY_ERR ret = LY_EVALID;
-    struct lysc_node *node, **children;
-    unsigned int u;
-    LY_ERR (*node_compile_spec)(struct lysc_ctx*, struct lysp_node*, int, struct lysc_node*);
-
-    switch (node_p->nodetype) {
-    case LYS_CONTAINER:
-        node = (struct lysc_node*)calloc(1, sizeof(struct lysc_node_container));
-        node_compile_spec = lys_compile_node_container;
-        break;
-    case LYS_LEAF:
-        node = (struct lysc_node*)calloc(1, sizeof(struct lysc_node_leaf));
-        node_compile_spec = lys_compile_node_leaf;
-        break;
-    case LYS_LIST:
-        node = (struct lysc_node*)calloc(1, sizeof(struct lysc_node_list));
-        break;
-    case LYS_LEAFLIST:
-        node = (struct lysc_node*)calloc(1, sizeof(struct lysc_node_leaflist));
-        break;
-    case LYS_CASE:
-        node = (struct lysc_node*)calloc(1, sizeof(struct lysc_node_case));
-        break;
-    case LYS_CHOICE:
-        node = (struct lysc_node*)calloc(1, sizeof(struct lysc_node_choice));
-        break;
-    case LYS_USES:
-        node = (struct lysc_node*)calloc(1, sizeof(struct lysc_node_uses));
-        break;
-    case LYS_ANYXML:
-    case LYS_ANYDATA:
-        node = (struct lysc_node*)calloc(1, sizeof(struct lysc_node_anydata));
-        break;
-    default:
-        LOGINT(ctx->ctx);
-        return LY_EINT;
-    }
-    LY_CHECK_ERR_RET(!node, LOGMEM(ctx->ctx), LY_EMEM);
-    node->nodetype = node_p->nodetype;
-    node->module = ctx->mod;
-    node->prev = node;
-    node->flags = node_p->flags;
-
-    /* config */
-    if (!(node->flags & LYS_CONFIG_MASK)) {
-        /* config not explicitely set, inherit it from parent */
-        if (parent) {
-            node->flags |= parent->flags & LYS_CONFIG_MASK;
-        } else {
-            /* default is config true */
-            node->flags |= LYS_CONFIG_W;
-        }
-    }
-
-    /* status - it is not inherited by specification, but it does not make sense to have
-     * current in deprecated or deprecated in obsolete, so we do print warning and inherit status */
-    if (!(node->flags & LYS_STATUS_MASK)) {
-        if (parent && (parent->flags & (LYS_STATUS_DEPRC | LYS_STATUS_OBSLT))) {
-            LOGWRN(ctx->ctx, "Missing explicit \"%s\" status that was already specified in parent, inheriting.",
-                   (parent->flags & LYS_STATUS_DEPRC) ? "deprecated" : "obsolete");
-            node->flags |= parent->flags & LYS_STATUS_MASK;
-        } else {
-            node->flags |= LYS_STATUS_CURR;
-        }
-    } else if (parent) {
-        /* check status compatibility with the parent */
-        if ((parent->flags & LYS_STATUS_MASK) > (node->flags & LYS_STATUS_MASK)) {
-            if (node->flags & LYS_STATUS_CURR) {
-                LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
-                       "A \"current\" status is in conflict with the parent's \"%s\" status.",
-                       (parent->flags & LYS_STATUS_DEPRC) ? "deprecated" : "obsolete");
-            } else { /* LYS_STATUS_DEPRC */
-                LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
-                       "A \"deprecated\" status is in conflict with the parent's \"obsolete\" status.");
-            }
-            goto error;
-        }
-    }
-
-    if (!(options & LYSC_OPT_FREE_SP)) {
-        node->sp = node_p;
-    }
-    DUP_STRING(ctx->ctx, node->name, node_p->name);
-    COMPILE_ARRAY_GOTO(ctx, node_p->exts, node->exts, options, u, lys_compile_ext, ret, error);
-
-    /* nodetype-specific part */
-    LY_CHECK_GOTO(node_compile_spec(ctx, node_p, options, node), error);
-
-    /* insert into parent's children */
-    if (parent && (children = lysc_node_children(parent))) {
-        if (!(*children)) {
-            /* first child */
-            *children = node;
-        } else {
-            /* insert at the end of the parent's children list */
-            (*children)->prev->next = node;
-            node->prev = (*children)->prev;
-            (*children)->prev = node;
-        }
-    } else {
-        /* top-level element */
-        if (!ctx->mod->compiled->data) {
-            ctx->mod->compiled->data = node;
-        } else {
-            /* insert at the end of the module's top-level nodes list */
-            ctx->mod->compiled->data->prev->next = node;
-            node->prev = ctx->mod->compiled->data->prev;
-            ctx->mod->compiled->data->prev = node;
-        }
-    }
-
-    return LY_SUCCESS;
-
-error:
-    lysc_node_free(ctx->ctx, node);
-    return ret;
-}
-
-LY_ERR
-lys_compile(struct lys_module *mod, int options)
-{
-    struct lysc_ctx ctx = {0};
-    struct lysc_module *mod_c;
-    struct lysp_module *sp;
-    struct lysp_node *node_p;
-    unsigned int u;
-    LY_ERR ret;
-
-    LY_CHECK_ARG_RET(NULL, mod, mod->parsed, mod->parsed->ctx, LY_EINVAL);
-    sp = mod->parsed;
-
-    if (sp->submodule) {
-        LOGERR(sp->ctx, LY_EINVAL, "Submodules (%s) are not supposed to be compiled, compile only the main modules.", sp->name);
-        return LY_EINVAL;
-    }
-
-    ctx.ctx = sp->ctx;
-    ctx.mod = mod;
-
-    mod->compiled = mod_c = calloc(1, sizeof *mod_c);
-    LY_CHECK_ERR_RET(!mod_c, LOGMEM(sp->ctx), LY_EMEM);
-    mod_c->ctx = sp->ctx;
-    mod_c->implemented = sp->implemented;
-    mod_c->latest_revision = sp->latest_revision;
-    mod_c->version = sp->version;
-
-    DUP_STRING(sp->ctx, mod_c->name, sp->name);
-    DUP_STRING(sp->ctx, mod_c->ns, sp->ns);
-    DUP_STRING(sp->ctx, mod_c->prefix, sp->prefix);
-    if (sp->revs) {
-        DUP_STRING(sp->ctx, mod_c->revision, sp->revs[0].date);
-    }
-    COMPILE_ARRAY_GOTO(&ctx, sp->imports, mod_c->imports, options, u, lys_compile_import, ret, error);
-    COMPILE_ARRAY_GOTO(&ctx, sp->features, mod_c->features, options, u, lys_compile_feature, ret, error);
-    COMPILE_ARRAY_GOTO(&ctx, sp->identities, mod_c->identities, options, u, lys_compile_identity, ret, error);
-    if (sp->identities) {
-        LY_CHECK_RET(lys_compile_identities_derived(&ctx, sp->identities, mod_c->identities));
-    }
-
-    LY_LIST_FOR(sp->data, node_p) {
-        ret = lys_compile_node(&ctx, node_p, options, NULL);
-        LY_CHECK_GOTO(ret, error);
-    }
-    //COMPILE_ARRAY_GOTO(ctx, sp->rpcs, mod_c->rpcs, options, u, lys_compile_action, ret, error);
-    //COMPILE_ARRAY_GOTO(ctx, sp->notifs, mod_c->notifs, options, u, lys_compile_notif, ret, error);
-
-    COMPILE_ARRAY_GOTO(&ctx, sp->exts, mod_c->exts, options, u, lys_compile_ext, ret, error);
-
-    if (options & LYSC_OPT_FREE_SP) {
-        lysp_module_free(mod->parsed);
-        ((struct lys_module*)mod)->parsed = NULL;
-    }
-
-    ((struct lys_module*)mod)->compiled = mod_c;
-    return LY_SUCCESS;
-
-error:
-    lysc_module_free(mod_c, NULL);
-    ((struct lys_module*)mod)->compiled = NULL;
-    return ret;
-}
-
 static void
 lys_latest_switch(struct lys_module *old, struct lysp_module *new)
 {
diff --git a/src/tree_schema_compile.c b/src/tree_schema_compile.c
new file mode 100644
index 0000000..7402f7e
--- /dev/null
+++ b/src/tree_schema_compile.c
@@ -0,0 +1,2010 @@
+/**
+ * @file tree_schema.c
+ * @author Radek Krejci <rkrejci@cesnet.cz>
+ * @brief Schema tree implementation
+ *
+ * Copyright (c) 2015 - 2018 CESNET, z.s.p.o.
+ *
+ * This source code is licensed under BSD 3-Clause License (the "License").
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     https://opensource.org/licenses/BSD-3-Clause
+ */
+
+#include "common.h"
+
+#include <ctype.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <linux/limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "libyang.h"
+#include "context.h"
+#include "tree_schema_internal.h"
+#include "xpath.h"
+
+/**
+ * @brief Duplicate string into dictionary
+ * @param[in] CTX libyang context of the dictionary.
+ * @param[in] ORIG String to duplicate.
+ * @param[out] DUP Where to store the result.
+ */
+#define DUP_STRING(CTX, ORIG, DUP) if (ORIG) {DUP = lydict_insert(CTX, ORIG, 0);}
+
+#define COMPILE_ARRAY_GOTO(CTX, ARRAY_P, ARRAY_C, OPTIONS, ITER, FUNC, RET, GOTO) \
+    if (ARRAY_P) { \
+        LY_ARRAY_CREATE_GOTO((CTX)->ctx, ARRAY_C, LY_ARRAY_SIZE(ARRAY_P), RET, GOTO); \
+        for (ITER = 0; ITER < LY_ARRAY_SIZE(ARRAY_P); ++ITER) { \
+            LY_ARRAY_INCREMENT(ARRAY_C); \
+            RET = FUNC(CTX, &(ARRAY_P)[ITER], OPTIONS, &(ARRAY_C)[ITER]); \
+            LY_CHECK_GOTO(RET != LY_SUCCESS, GOTO); \
+        } \
+    }
+
+#define COMPILE_MEMBER_GOTO(CTX, MEMBER_P, MEMBER_C, OPTIONS, FUNC, RET, GOTO) \
+    if (MEMBER_P) { \
+        MEMBER_C = calloc(1, sizeof *(MEMBER_C)); \
+        LY_CHECK_ERR_GOTO(!(MEMBER_C), LOGMEM((CTX)->ctx); RET = LY_EMEM, GOTO); \
+        RET = FUNC(CTX, MEMBER_P, OPTIONS, MEMBER_C); \
+        LY_CHECK_GOTO(RET != LY_SUCCESS, GOTO); \
+    }
+
+const char* ly_data_type2str[LY_DATA_TYPE_COUNT] = {"unknown", "binary", "bits", "boolean", "decimal64", "empty", "enumeration",
+    "identityref", "instance-identifier", "leafref", "string", "union", "8bit integer", "8bit unsigned integer", "16bit integer",
+    "16bit unsigned integer", "32bit integer", "32bit unsigned integer", "64bit integer", "64bit unsigned integer"
+};
+
+static struct lysc_ext_instance *
+lysc_ext_instance_dup(struct ly_ctx *ctx, struct lysc_ext_instance *orig)
+{
+    /* TODO */
+    (void) ctx;
+    (void) orig;
+    return NULL;
+}
+
+static struct lysc_pattern*
+lysc_pattern_dup(struct lysc_pattern *orig)
+{
+    ++orig->refcount;
+    return orig;
+}
+
+static struct lysc_pattern**
+lysc_patterns_dup(struct ly_ctx *ctx, struct lysc_pattern **orig)
+{
+    struct lysc_pattern **dup;
+    unsigned int u;
+
+    LY_ARRAY_CREATE_RET(ctx, dup, LY_ARRAY_SIZE(orig), NULL);
+    LY_ARRAY_FOR(orig, u) {
+        dup[u] = lysc_pattern_dup(orig[u]);
+        LY_ARRAY_INCREMENT(dup);
+    }
+    return dup;
+}
+
+struct lysc_range*
+lysc_range_dup(struct ly_ctx *ctx, const struct lysc_range *orig)
+{
+    struct lysc_range *dup;
+    LY_ERR ret;
+
+    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);
+    }
+    DUP_STRING(ctx, orig->eapptag, dup->eapptag);
+    DUP_STRING(ctx, orig->emsg, dup->emsg);
+    dup->exts = lysc_ext_instance_dup(ctx, orig->exts);
+
+    return dup;
+cleanup:
+    free(dup);
+    (void) ret; /* set but not used due to the return type */
+    return NULL;
+}
+
+struct iff_stack {
+    int size;
+    int index;     /* first empty item */
+    uint8_t *stack;
+};
+
+static LY_ERR
+iff_stack_push(struct iff_stack *stack, uint8_t value)
+{
+    if (stack->index == stack->size) {
+        stack->size += 4;
+        stack->stack = ly_realloc(stack->stack, stack->size * sizeof *stack->stack);
+        LY_CHECK_ERR_RET(!stack->stack, LOGMEM(NULL); stack->size = 0, LY_EMEM);
+    }
+    stack->stack[stack->index++] = value;
+    return LY_SUCCESS;
+}
+
+static uint8_t
+iff_stack_pop(struct iff_stack *stack)
+{
+    stack->index--;
+    return stack->stack[stack->index];
+}
+
+static void
+iff_stack_clean(struct iff_stack *stack)
+{
+    stack->size = 0;
+    free(stack->stack);
+}
+
+static void
+iff_setop(uint8_t *list, uint8_t op, int pos)
+{
+    uint8_t *item;
+    uint8_t mask = 3;
+
+    assert(pos >= 0);
+    assert(op <= 3); /* max 2 bits */
+
+    item = &list[pos / 4];
+    mask = mask << 2 * (pos % 4);
+    *item = (*item) & ~mask;
+    *item = (*item) | (op << 2 * (pos % 4));
+}
+
+#define LYS_IFF_LP 0x04 /* ( */
+#define LYS_IFF_RP 0x08 /* ) */
+
+static struct lysc_feature *
+lysc_feature_find(struct lysc_module *mod, const char *name, size_t len)
+{
+    size_t i;
+    struct lysc_feature *f;
+
+    for (i = 0; i < len; ++i) {
+        if (name[i] == ':') {
+            /* we have a prefixed feature */
+            mod = lysc_module_find_prefix(mod, name, i);
+            LY_CHECK_RET(!mod, NULL);
+
+            name = &name[i + 1];
+            len = len - i - 1;
+        }
+    }
+
+    /* we have the correct module, get the feature */
+    LY_ARRAY_FOR(mod->features, i) {
+        f = &mod->features[i];
+        if (!strncmp(f->name, name, len) && f->name[len] == '\0') {
+            return f;
+        }
+    }
+
+    return NULL;
+}
+
+static LY_ERR
+lys_compile_ext(struct lysc_ctx *ctx, struct lysp_ext_instance *ext_p, int UNUSED(options), struct lysc_ext_instance *ext)
+{
+    const char *name;
+    unsigned int u;
+    const struct lys_module *mod;
+    struct lysp_ext *edef = NULL;
+
+    DUP_STRING(ctx->ctx, ext_p->argument, ext->argument);
+    ext->insubstmt = ext_p->insubstmt;
+    ext->insubstmt_index = ext_p->insubstmt_index;
+
+    /* get module where the extension definition should be placed */
+    for (u = 0; ext_p->name[u] != ':'; ++u);
+    mod = lys_module_find_prefix(ctx->mod, ext_p->name, u);
+    LY_CHECK_ERR_RET(!mod, LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
+                                  "Invalid prefix \"%.*s\" used for extension instance identifier.", u, ext_p->name),
+                     LY_EVALID);
+    LY_CHECK_ERR_RET(!mod->parsed->extensions,
+                     LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
+                            "Extension instance \"%s\" refers \"%s\" module that does not contain extension definitions.",
+                            ext_p->name, mod->parsed->name),
+                     LY_EVALID);
+    name = &ext_p->name[u + 1];
+    /* find the extension definition there */
+    for (ext = NULL, u = 0; u < LY_ARRAY_SIZE(mod->parsed->extensions); ++u) {
+        if (!strcmp(name, mod->parsed->extensions[u].name)) {
+            edef = &mod->parsed->extensions[u];
+            break;
+        }
+    }
+    LY_CHECK_ERR_RET(!edef, LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
+                                   "Extension definition of extension instance \"%s\" not found.", ext_p->name),
+                     LY_EVALID);
+    /* TODO plugins */
+
+    return LY_SUCCESS;
+}
+
+static LY_ERR
+lys_compile_iffeature(struct lysc_ctx *ctx, const char **value, int UNUSED(options), struct lysc_iffeature *iff)
+{
+    const char *c = *value;
+    int r, rc = EXIT_FAILURE;
+    int i, j, last_not, checkversion = 0;
+    unsigned int f_size = 0, expr_size = 0, f_exp = 1;
+    uint8_t op;
+    struct iff_stack stack = {0, 0, NULL};
+    struct lysc_feature *f;
+
+    assert(c);
+
+    /* pre-parse the expression to get sizes for arrays, also do some syntax checks of the expression */
+    for (i = j = last_not = 0; c[i]; i++) {
+        if (c[i] == '(') {
+            j++;
+            checkversion = 1;
+            continue;
+        } else if (c[i] == ')') {
+            j--;
+            continue;
+        } else if (isspace(c[i])) {
+            checkversion = 1;
+            continue;
+        }
+
+        if (!strncmp(&c[i], "not", r = 3) || !strncmp(&c[i], "and", r = 3) || !strncmp(&c[i], "or", r = 2)) {
+            if (c[i + r] == '\0') {
+                LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
+                       "Invalid value \"%s\" of if-feature - unexpected end of expression.", *value);
+                return LY_EVALID;
+            } else if (!isspace(c[i + r])) {
+                /* feature name starting with the not/and/or */
+                last_not = 0;
+                f_size++;
+            } else if (c[i] == 'n') { /* not operation */
+                if (last_not) {
+                    /* double not */
+                    expr_size = expr_size - 2;
+                    last_not = 0;
+                } else {
+                    last_not = 1;
+                }
+            } else { /* and, or */
+                f_exp++;
+                /* not a not operation */
+                last_not = 0;
+            }
+            i += r;
+        } else {
+            f_size++;
+            last_not = 0;
+        }
+        expr_size++;
+
+        while (!isspace(c[i])) {
+            if (!c[i] || c[i] == ')') {
+                i--;
+                break;
+            }
+            i++;
+        }
+    }
+    if (j || f_exp != f_size) {
+        /* not matching count of ( and ) */
+        LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
+               "Invalid value \"%s\" of if-feature - non-matching opening and closing parentheses.", *value);
+        return LY_EVALID;
+    }
+
+    if (checkversion || expr_size > 1) {
+        /* check that we have 1.1 module */
+        if (ctx->mod->compiled->version != LYS_VERSION_1_1) {
+            LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
+                   "Invalid value \"%s\" of if-feature - YANG 1.1 expression in YANG 1.0 module.", *value);
+            return LY_EVALID;
+        }
+    }
+
+    /* allocate the memory */
+    LY_ARRAY_CREATE_RET(ctx->ctx, iff->features, f_size, LY_EMEM);
+    iff->expr = calloc((j = (expr_size / 4) + ((expr_size % 4) ? 1 : 0)), sizeof *iff->expr);
+    stack.stack = malloc(expr_size * sizeof *stack.stack);
+    LY_CHECK_ERR_GOTO(!stack.stack || !iff->expr, LOGMEM(ctx->ctx), error);
+
+    stack.size = expr_size;
+    f_size--; expr_size--; /* used as indexes from now */
+
+    for (i--; i >= 0; i--) {
+        if (c[i] == ')') {
+            /* push it on stack */
+            iff_stack_push(&stack, LYS_IFF_RP);
+            continue;
+        } else if (c[i] == '(') {
+            /* pop from the stack into result all operators until ) */
+            while((op = iff_stack_pop(&stack)) != LYS_IFF_RP) {
+                iff_setop(iff->expr, op, expr_size--);
+            }
+            continue;
+        } else if (isspace(c[i])) {
+            continue;
+        }
+
+        /* end of operator or operand -> find beginning and get what is it */
+        j = i + 1;
+        while (i >= 0 && !isspace(c[i]) && c[i] != '(') {
+            i--;
+        }
+        i++; /* go back by one step */
+
+        if (!strncmp(&c[i], "not", 3) && isspace(c[i + 3])) {
+            if (stack.index && stack.stack[stack.index - 1] == LYS_IFF_NOT) {
+                /* double not */
+                iff_stack_pop(&stack);
+            } else {
+                /* not has the highest priority, so do not pop from the stack
+                 * as in case of AND and OR */
+                iff_stack_push(&stack, LYS_IFF_NOT);
+            }
+        } else if (!strncmp(&c[i], "and", 3) && isspace(c[i + 3])) {
+            /* as for OR - pop from the stack all operators with the same or higher
+             * priority and store them to the result, then push the AND to the stack */
+            while (stack.index && stack.stack[stack.index - 1] <= LYS_IFF_AND) {
+                op = iff_stack_pop(&stack);
+                iff_setop(iff->expr, op, expr_size--);
+            }
+            iff_stack_push(&stack, LYS_IFF_AND);
+        } else if (!strncmp(&c[i], "or", 2) && isspace(c[i + 2])) {
+            while (stack.index && stack.stack[stack.index - 1] <= LYS_IFF_OR) {
+                op = iff_stack_pop(&stack);
+                iff_setop(iff->expr, op, expr_size--);
+            }
+            iff_stack_push(&stack, LYS_IFF_OR);
+        } else {
+            /* feature name, length is j - i */
+
+            /* add it to the expression */
+            iff_setop(iff->expr, LYS_IFF_F, expr_size--);
+
+            /* now get the link to the feature definition */
+            f = lysc_feature_find(ctx->mod->compiled, &c[i], j - i);
+            LY_CHECK_ERR_GOTO(!f,
+                              LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
+                                     "Invalid value \"%s\" of if-feature - unable to find feature \"%.*s\".", *value, j - i, &c[i]);
+                              rc = LY_EVALID,
+                              error)
+            iff->features[f_size] = f;
+            LY_ARRAY_INCREMENT(iff->features);
+            f_size--;
+        }
+    }
+    while (stack.index) {
+        op = iff_stack_pop(&stack);
+        iff_setop(iff->expr, op, expr_size--);
+    }
+
+    if (++expr_size || ++f_size) {
+        /* not all expected operators and operands found */
+        LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
+               "Invalid value \"%s\" of if-feature - processing error.", *value);
+        rc = LY_EINT;
+    } else {
+        rc = LY_SUCCESS;
+    }
+
+error:
+    /* cleanup */
+    iff_stack_clean(&stack);
+
+    return rc;
+}
+
+static LY_ERR
+lys_compile_when(struct lysc_ctx *ctx, struct lysp_when *when_p, int options, struct lysc_when *when)
+{
+    unsigned int u;
+    LY_ERR ret = LY_SUCCESS;
+
+    when->cond = lyxp_expr_parse(ctx->ctx, when_p->cond);
+    LY_CHECK_ERR_GOTO(!when->cond, ret = ly_errcode(ctx->ctx), done);
+    COMPILE_ARRAY_GOTO(ctx, when_p->exts, when->exts, options, u, lys_compile_ext, ret, done);
+
+done:
+    return ret;
+}
+
+static LY_ERR
+lys_compile_must(struct lysc_ctx *ctx, struct lysp_restr *must_p, int options, struct lysc_must *must)
+{
+    unsigned int u;
+    LY_ERR ret = LY_SUCCESS;
+
+    must->cond = lyxp_expr_parse(ctx->ctx, must_p->arg);
+    LY_CHECK_ERR_GOTO(!must->cond, ret = ly_errcode(ctx->ctx), done);
+
+    DUP_STRING(ctx->ctx, must_p->eapptag, must->eapptag);
+    DUP_STRING(ctx->ctx, must_p->emsg, must->emsg);
+    COMPILE_ARRAY_GOTO(ctx, must_p->exts, must->exts, options, u, lys_compile_ext, ret, done);
+
+done:
+    return ret;
+}
+
+static LY_ERR
+lys_compile_import(struct lysc_ctx *ctx, struct lysp_import *imp_p, int options, struct lysc_import *imp)
+{
+    unsigned int u;
+    struct lys_module *mod = NULL;
+    struct lysc_module *comp;
+    LY_ERR ret = LY_SUCCESS;
+
+    DUP_STRING(ctx->ctx, imp_p->prefix, imp->prefix);
+    COMPILE_ARRAY_GOTO(ctx, imp_p->exts, imp->exts, options, u, lys_compile_ext, ret, done);
+    imp->module = imp_p->module;
+
+    /* make sure that we have both versions (lysp_ and lysc_) of the imported module. To import groupings or
+     * typedefs, the lysp_ is needed. To augment or deviate imported module, we need the lysc_ structure */
+    if (!imp->module->parsed) {
+        comp = imp->module->compiled;
+        /* try to get filepath from the compiled version */
+        if (comp->filepath) {
+            mod = (struct lys_module*)lys_parse_path(ctx->ctx, comp->filepath,
+                                 !strcmp(&comp->filepath[strlen(comp->filepath - 4)], ".yin") ? LYS_IN_YIN : LYS_IN_YANG);
+            if (mod != imp->module) {
+                LOGERR(ctx->ctx, LY_EINT, "Filepath \"%s\" of the module \"%s\" does not match.",
+                       comp->filepath, comp->name);
+                mod = NULL;
+            }
+        }
+        if (!mod) {
+            if (lysp_load_module(ctx->ctx, comp->name, comp->revision, 0, 1, &mod)) {
+                LOGERR(ctx->ctx, LY_ENOTFOUND, "Unable to reload \"%s\" module to import it into \"%s\", source data not found.",
+                       comp->name, ctx->mod->compiled->name);
+                return LY_ENOTFOUND;
+            }
+        }
+    } else if (!imp->module->compiled) {
+        return lys_compile(imp->module, options);
+    }
+
+done:
+    return ret;
+}
+
+static LY_ERR
+lys_compile_identity(struct lysc_ctx *ctx, struct lysp_ident *ident_p, int options, struct lysc_ident *ident)
+{
+    unsigned int u;
+    LY_ERR ret = LY_SUCCESS;
+
+    DUP_STRING(ctx->ctx, ident_p->name, ident->name);
+    COMPILE_ARRAY_GOTO(ctx, ident_p->iffeatures, ident->iffeatures, options, u, lys_compile_iffeature, ret, done);
+    /* backlings (derived) can be added no sooner than when all the identities in the current module are present */
+    COMPILE_ARRAY_GOTO(ctx, ident_p->exts, ident->exts, options, u, lys_compile_ext, ret, done);
+    ident->flags = ident_p->flags;
+
+done:
+    return ret;
+}
+
+static LY_ERR
+lys_compile_identities_derived(struct lysc_ctx *ctx, struct lysp_ident *idents_p, struct lysc_ident *idents)
+{
+    unsigned int i, u, v;
+    const char *s, *name;
+    struct lysc_module *mod;
+    struct lysc_ident **dident;
+
+    for (i = 0; i < LY_ARRAY_SIZE(idents_p); ++i) {
+        if (!idents_p[i].bases) {
+            continue;
+        }
+        for (u = 0; u < LY_ARRAY_SIZE(idents_p[i].bases); ++u) {
+            s = strchr(idents_p[i].bases[u], ':');
+            if (s) {
+                /* prefixed identity */
+                name = &s[1];
+                mod = lysc_module_find_prefix(ctx->mod->compiled, idents_p[i].bases[u], s - idents_p[i].bases[u]);
+            } else {
+                name = idents_p[i].bases[u];
+                mod = ctx->mod->compiled;
+            }
+            LY_CHECK_ERR_RET(!mod, LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
+                                          "Invalid prefix used for base (%s) of identity \"%s\".", idents_p[i].bases[u], idents[i].name),
+                             LY_EVALID);
+            if (mod->identities) {
+                for (v = 0; v < LY_ARRAY_SIZE(mod->identities); ++v) {
+                    if (!strcmp(name, mod->identities[v].name)) {
+                        /* we have match! store the backlink */
+                        LY_ARRAY_NEW_RET(ctx->ctx, mod->identities[v].derived, dident, LY_EMEM);
+                        *dident = &idents[i];
+                        break;
+                    }
+                }
+            }
+            LY_CHECK_ERR_RET(!dident, LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
+                                             "Unable to find base (%s) of identity \"%s\".", idents_p[i].bases[u], idents[i].name),
+                             LY_EVALID);
+        }
+    }
+    return LY_SUCCESS;
+}
+
+static LY_ERR
+lys_compile_feature(struct lysc_ctx *ctx, struct lysp_feature *feature_p, int options, struct lysc_feature *feature)
+{
+    unsigned int u, v;
+    LY_ERR ret = LY_SUCCESS;
+    struct lysc_feature **df;
+
+    DUP_STRING(ctx->ctx, feature_p->name, feature->name);
+    feature->flags = feature_p->flags;
+
+    COMPILE_ARRAY_GOTO(ctx, feature_p->exts, feature->exts, options, u, lys_compile_ext, ret, done);
+    COMPILE_ARRAY_GOTO(ctx, feature_p->iffeatures, feature->iffeatures, options, u, lys_compile_iffeature, ret, done);
+    if (feature->iffeatures) {
+        for (u = 0; u < LY_ARRAY_SIZE(feature->iffeatures); ++u) {
+            if (feature->iffeatures[u].features) {
+                for (v = 0; v < LY_ARRAY_SIZE(feature->iffeatures[u].features); ++v) {
+                    /* add itself into the dependants list */
+                    LY_ARRAY_NEW_RET(ctx->ctx, feature->iffeatures[u].features[v]->depfeatures, df, LY_EMEM);
+                    *df = feature;
+                }
+                /* TODO check for circular dependency */
+            }
+        }
+    }
+done:
+    return ret;
+}
+
+static LY_ERR
+range_part_check_value_syntax(struct lysc_ctx *ctx, LY_DATA_TYPE basetype, const char *value, size_t *len, char **valcopy)
+{
+    size_t fraction = 0;
+    *len = 0;
+
+    assert(value);
+    /* parse value */
+    if (!isdigit(value[*len]) && (value[*len] != '-') && (value[*len] != '+')) {
+        return LY_EVALID;
+    }
+
+    if ((value[*len] == '-') || (value[*len] == '+')) {
+        ++(*len);
+    }
+
+    while (isdigit(value[*len])) {
+        ++(*len);
+    }
+
+    if ((basetype != LY_TYPE_DEC64) || (value[*len] != '.') || !isdigit(value[*len + 1])) {
+        *valcopy = strndup(value, *len);
+        return LY_SUCCESS;
+    }
+    fraction = *len;
+
+    ++(*len);
+    while (isdigit(value[*len])) {
+        ++(*len);
+    }
+
+    if (fraction) {
+        *valcopy = malloc(((*len) - 1) * sizeof **valcopy);
+        LY_CHECK_ERR_RET(!(*valcopy), LOGMEM(ctx->ctx), LY_EMEM);
+
+        *valcopy[(*len) - 1] = '\0';
+        memcpy(&(*valcopy)[0], &value[0], fraction);
+        memcpy(&(*valcopy)[fraction], &value[fraction + 1], (*len) - 1 - (fraction + 1));
+    }
+    return LY_SUCCESS;
+}
+
+static LY_ERR
+range_part_check_ascendance(int unsigned_value, int64_t value, int64_t prev_value)
+{
+    if (unsigned_value) {
+        if ((uint64_t)prev_value >= (uint64_t)value) {
+            return LY_EEXIST;
+        }
+    } else {
+        if (prev_value >= value) {
+            return LY_EEXIST;
+        }
+    }
+    return LY_SUCCESS;
+}
+
+static LY_ERR
+range_part_minmax(struct lysc_ctx *ctx, struct lysc_range_part *part, int max, int64_t prev, LY_DATA_TYPE basetype, int first, int length_restr,
+                  const char **value)
+{
+    LY_ERR ret = LY_SUCCESS;
+    char *valcopy = NULL;
+    size_t len;
+
+    if (value) {
+        ret = range_part_check_value_syntax(ctx, basetype, *value, &len, &valcopy);
+        LY_CHECK_GOTO(ret, error);
+    }
+
+    switch (basetype) {
+    case LY_TYPE_BINARY: /* length */
+        if (valcopy) {
+            ret = ly_parse_uint(valcopy, UINT64_C(18446744073709551615), 10, max ? &part->max_u64 : &part->min_u64);
+        } else if (max) {
+            part->max_u64 = UINT64_C(18446744073709551615);
+        } else {
+            part->min_u64 = UINT64_C(0);
+        }
+        if (!first) {
+            ret = range_part_check_ascendance(1, max ? part->max_64 : part->min_64, prev);
+        }
+        break;
+    case LY_TYPE_DEC64: /* range */
+        if (valcopy) {
+            ret = ly_parse_int(valcopy, INT64_C(-9223372036854775807) - INT64_C(1), INT64_C(9223372036854775807), 10,
+                               max ? &part->max_64 : &part->min_64);
+        } else if (max) {
+            part->max_64 = INT64_C(9223372036854775807);
+        } else {
+            part->min_64 = INT64_C(-9223372036854775807) - INT64_C(1);
+        }
+        if (!first) {
+            ret = range_part_check_ascendance(0, max ? part->max_64 : part->min_64, prev);
+        }
+        break;
+    case LY_TYPE_INT8: /* range */
+        if (valcopy) {
+            ret = ly_parse_int(valcopy, INT64_C(-128), INT64_C(127), 10, max ? &part->max_64 : &part->min_64);
+        } else if (max) {
+            part->max_64 = INT64_C(127);
+        } else {
+            part->min_64 = INT64_C(-128);
+        }
+        if (!first) {
+            ret = range_part_check_ascendance(0, max ? part->max_64 : part->min_64, prev);
+        }
+        break;
+    case LY_TYPE_INT16: /* range */
+        if (valcopy) {
+            ret = ly_parse_int(valcopy, INT64_C(-32768), INT64_C(32767), 10, max ? &part->max_64 : &part->min_64);
+        } else if (max) {
+            part->max_64 = INT64_C(32767);
+        } else {
+            part->min_64 = INT64_C(-32768);
+        }
+        if (!first) {
+            ret = range_part_check_ascendance(0, max ? part->max_64 : part->min_64, prev);
+        }
+        break;
+    case LY_TYPE_INT32: /* range */
+        if (valcopy) {
+            ret = ly_parse_int(valcopy, INT64_C(-2147483648), INT64_C(2147483647), 10, max ? &part->max_64 : &part->min_64);
+        } else if (max) {
+            part->max_64 = INT64_C(2147483647);
+        } else {
+            part->min_64 = INT64_C(-2147483648);
+        }
+        if (!first) {
+            ret = range_part_check_ascendance(0, max ? part->max_64 : part->min_64, prev);
+        }
+        break;
+    case LY_TYPE_INT64: /* range */
+        if (valcopy) {
+            ret = ly_parse_int(valcopy, INT64_C(-9223372036854775807) - INT64_C(1), INT64_C(9223372036854775807), 10,
+                               max ? &part->max_64 : &part->min_64);
+        } else if (max) {
+            part->max_64 = INT64_C(9223372036854775807);
+        } else {
+            part->min_64 = INT64_C(-9223372036854775807) - INT64_C(1);
+        }
+        if (!first) {
+            ret = range_part_check_ascendance(0, max ? part->max_64 : part->min_64, prev);
+        }
+        break;
+    case LY_TYPE_UINT8: /* range */
+        if (valcopy) {
+            ret = ly_parse_uint(valcopy, UINT64_C(255), 10, max ? &part->max_u64 : &part->min_u64);
+        } else if (max) {
+            part->max_u64 = UINT64_C(255);
+        } else {
+            part->min_u64 = UINT64_C(0);
+        }
+        if (!first) {
+            ret = range_part_check_ascendance(1, max ? part->max_64 : part->min_64, prev);
+        }
+        break;
+    case LY_TYPE_UINT16: /* range */
+        if (valcopy) {
+            ret = ly_parse_uint(valcopy, UINT64_C(65535), 10, max ? &part->max_u64 : &part->min_u64);
+        } else if (max) {
+            part->max_u64 = UINT64_C(65535);
+        } else {
+            part->min_u64 = UINT64_C(0);
+        }
+        if (!first) {
+            ret = range_part_check_ascendance(1, max ? part->max_64 : part->min_64, prev);
+        }
+        break;
+    case LY_TYPE_UINT32: /* range */
+        if (valcopy) {
+            ret = ly_parse_uint(valcopy, UINT64_C(4294967295), 10, max ? &part->max_u64 : &part->min_u64);
+        } else if (max) {
+            part->max_u64 = UINT64_C(4294967295);
+        } else {
+            part->min_u64 = UINT64_C(0);
+        }
+        if (!first) {
+            ret = range_part_check_ascendance(1, max ? part->max_64 : part->min_64, prev);
+        }
+        break;
+    case LY_TYPE_UINT64: /* range */
+        if (valcopy) {
+            ret = ly_parse_uint(valcopy, UINT64_C(18446744073709551615), 10, max ? &part->max_u64 : &part->min_u64);
+        } else if (max) {
+            part->max_u64 = UINT64_C(18446744073709551615);
+        } else {
+            part->min_u64 = UINT64_C(0);
+        }
+        if (!first) {
+            ret = range_part_check_ascendance(1, max ? part->max_64 : part->min_64, prev);
+        }
+        break;
+    case LY_TYPE_STRING: /* length */
+        if (valcopy) {
+            ret = ly_parse_uint(valcopy, UINT64_C(18446744073709551615), 10, max ? &part->max_u64 : &part->min_u64);
+        } else if (max) {
+            part->max_u64 = UINT64_C(18446744073709551615);
+        } else {
+            part->min_u64 = UINT64_C(0);
+        }
+        if (!first) {
+            ret = range_part_check_ascendance(1, max ? part->max_64 : part->min_64, prev);
+        }
+        break;
+    default:
+        LOGINT(ctx->ctx);
+        ret = LY_EINT;
+    }
+
+error:
+    if (ret == LY_EDENIED) {
+        LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
+               "Invalid %s restriction - value \"%s\" does not fit the type limitations.",
+               length_restr ? "length" : "range", valcopy ? valcopy : *value);
+    } else if (ret == LY_EVALID) {
+        LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
+               "Invalid %s restriction - invalid value \"%s\".",
+               length_restr ? "length" : "range", valcopy ? valcopy : *value);
+    } else if (ret == LY_EEXIST) {
+        LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
+                       "Invalid %s restriction - values are not in ascending order (%s).",
+                       length_restr ? "length" : "range", valcopy ? valcopy : *value);
+    } else if (!ret && value) {
+        *value = *value + len;
+    }
+    free(valcopy);
+    return ret;
+}
+
+static LY_ERR
+lys_compile_type_range(struct lysc_ctx *ctx, struct lysp_restr *range_p, LY_DATA_TYPE basetype, int length_restr,
+                       struct lysc_range *base_range, struct lysc_range **range)
+{
+    LY_ERR ret = LY_EVALID;
+    const char *expr;
+    struct lysc_range_part *parts = NULL, *part;
+    int range_expected = 0, uns;
+    unsigned int parts_done = 0, u, v;
+
+    assert(range);
+    assert(range_p);
+
+    expr = range_p->arg;
+    while(1) {
+        if (isspace(*expr)) {
+            ++expr;
+        } else if (*expr == '\0') {
+            if (range_expected) {
+                LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
+                       "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)) {
+                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);
+                goto cleanup;
+            }
+            parts_done++;
+            break;
+        } else if (!strncmp(expr, "min", 3)) {
+            if (parts) {
+                /* min cannot be used elsewhere than in the first part */
+                LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
+                       "Invalid %s restriction - unexpected data before min keyword (%.*s).", length_restr ? "length" : "range",
+                       expr - range_p->arg, range_p->arg);
+                goto cleanup;
+            }
+            expr += 3;
+
+            LY_ARRAY_NEW_GOTO(ctx->ctx, parts, part, ret, cleanup);
+            LY_CHECK_GOTO(range_part_minmax(ctx, part, 0, 0, basetype, 1, length_restr, NULL), cleanup);
+            part->max_64 = part->min_64;
+        } else if (*expr == '|') {
+            if (!parts || range_expected) {
+                LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
+                       "Invalid %s restriction - unexpected beginning of the expression (%s).", length_restr ? "length" : "range", expr);
+                goto cleanup;
+            }
+            expr++;
+            parts_done++;
+            /* process next part of the expression */
+        } else if (!strncmp(expr, "..", 2)) {
+            expr += 2;
+            while (isspace(*expr)) {
+                expr++;
+            }
+            if (!parts || LY_ARRAY_SIZE(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;
+            }
+            /* continue expecting the upper boundary */
+            range_expected = 1;
+        } else if (isdigit(*expr) || (*expr == '-') || (*expr == '+')) {
+            /* number */
+            if (range_expected) {
+                part = &parts[LY_ARRAY_SIZE(parts) - 1];
+                LY_CHECK_GOTO(range_part_minmax(ctx, part, 1, part->min_64, basetype, 0, length_restr, &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,
+                                                basetype, parts_done ? 0 : 1, length_restr, &expr), cleanup);
+                part->max_64 = part->min_64;
+            }
+
+            /* continue with possible another expression part */
+        } else if (!strncmp(expr, "max", 3)) {
+            expr += 3;
+            while (isspace(*expr)) {
+                expr++;
+            }
+            if (*expr != '\0') {
+                LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG, "Invalid %s restriction - unexpected data after max keyword (%s).",
+                       length_restr ? "length" : "range", expr);
+                goto cleanup;
+            }
+            if (range_expected) {
+                part = &parts[LY_ARRAY_SIZE(parts) - 1];
+                LY_CHECK_GOTO(range_part_minmax(ctx, part, 1, part->min_64, basetype, 0, length_restr, 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,
+                                                basetype, parts_done ? 0 : 1, length_restr, NULL), cleanup);
+                part->min_64 = part->max_64;
+            }
+        } else {
+            LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG, "Invalid %s restriction - unexpected data (%s).",
+                   length_restr ? "length" : "range", expr);
+            goto cleanup;
+        }
+    }
+
+    /* check with the previous range/length restriction */
+    if (base_range) {
+        switch (basetype) {
+        case LY_TYPE_BINARY:
+        case LY_TYPE_UINT8:
+        case LY_TYPE_UINT16:
+        case LY_TYPE_UINT32:
+        case LY_TYPE_UINT64:
+        case LY_TYPE_STRING:
+            uns = 1;
+            break;
+        case LY_TYPE_DEC64:
+        case LY_TYPE_INT8:
+        case LY_TYPE_INT16:
+        case LY_TYPE_INT32:
+        case LY_TYPE_INT64:
+            uns = 0;
+            break;
+        default:
+            LOGINT(ctx->ctx);
+            ret = LY_EINT;
+            goto cleanup;
+        }
+        for (u = v = 0; u < parts_done && v < LY_ARRAY_SIZE(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;
+            }
+            /* current lower bound is not lower than the base */
+            if (base_range->parts[v].min_64 == base_range->parts[v].max_64) {
+                /* base has single value */
+                if (base_range->parts[v].min_64 == parts[u].min_64) {
+                    /* both lower bounds are the same */
+                    if (parts[u].min_64 != parts[u].max_64) {
+                        /* current continues with a range */
+                        goto baseerror;
+                    } else {
+                        /* equal single values, move both forward */
+                        ++v;
+                        continue;
+                    }
+                } else {
+                    /* base is single value lower than current range, so the
+                     * value from base range is removed in the current,
+                     * move only base and repeat checking */
+                    ++v;
+                    --u;
+                    continue;
+                }
+            } else {
+                /* base is the range */
+                if (parts[u].min_64 == parts[u].max_64) {
+                    /* current is a single value */
+                    if ((uns && parts[u].max_u64 > base_range->parts[v].max_u64) || (!uns && parts[u].max_64 > base_range->parts[v].max_64)) {
+                        /* current is behind the base range, so base range is omitted,
+                         * move the base and keep the current for further check */
+                        ++v;
+                        --u;
+                    } /* else it is within the base range, so move the current, but keep the base */
+                    continue;
+                } else {
+                    /* both are ranges - check the higher bound, the lower was already checked */
+                    if ((uns && parts[u].max_u64 > base_range->parts[v].max_u64) || (!uns && parts[u].max_64 > base_range->parts[v].max_64)) {
+                        /* higher bound is higher than the current higher bound */
+                        if ((uns && parts[u].min_u64 > base_range->parts[v].max_u64) || (!uns && parts[u].min_64 > base_range->parts[v].max_64)) {
+                            /* but the current lower bound is also higher, so the base range is omitted,
+                             * continue with the same current, but move the base */
+                            --u;
+                            ++v;
+                            continue;
+                        }
+                        /* current range starts within the base range but end behind it */
+                        goto baseerror;
+                    } else {
+                        /* current range is smaller than the base,
+                         * move current, but stay with the base */
+                        continue;
+                    }
+                }
+            }
+        }
+        if (u != parts_done) {
+baseerror:
+            LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
+                   "Invalid %s restriction - the derived restriction (%s) is not equally or more limiting.",
+                   length_restr ? "length" : "range", range_p->arg);
+            goto cleanup;
+        }
+    }
+
+    if (!(*range)) {
+        *range = calloc(1, sizeof **range);
+        LY_CHECK_ERR_RET(!(*range), LOGMEM(ctx->ctx), LY_EMEM);
+    }
+
+    if (range_p->eapptag) {
+        lydict_remove(ctx->ctx, (*range)->eapptag);
+        (*range)->eapptag = lydict_insert(ctx->ctx, range_p->eapptag, 0);
+    }
+    if (range_p->emsg) {
+        lydict_remove(ctx->ctx, (*range)->emsg);
+        (*range)->emsg = lydict_insert(ctx->ctx, range_p->emsg, 0);
+    }
+    /* extensions are taken only from the last range by the caller */
+
+    (*range)->parts = parts;
+    parts = NULL;
+    ret = LY_SUCCESS;
+cleanup:
+    /* TODO clean up */
+    LY_ARRAY_FREE(parts);
+
+    return ret;
+}
+
+/**
+ * @brief Checks pattern syntax.
+ *
+ * @param[in] pattern Pattern to check.
+ * @param[out] pcre_precomp Precompiled PCRE pattern. Can be NULL.
+ * @return EXIT_SUCCESS on success, EXIT_FAILURE otherwise.
+ */
+static LY_ERR
+lys_compile_type_pattern_check(struct lysc_ctx *ctx, const char *pattern, pcre **pcre_precomp)
+{
+    int idx, idx2, start, end, err_offset, count;
+    char *perl_regex, *ptr;
+    const char *err_msg, *orig_ptr;
+    pcre *precomp;
+#define URANGE_LEN 19
+    char *ublock2urange[][2] = {
+        {"BasicLatin", "[\\x{0000}-\\x{007F}]"},
+        {"Latin-1Supplement", "[\\x{0080}-\\x{00FF}]"},
+        {"LatinExtended-A", "[\\x{0100}-\\x{017F}]"},
+        {"LatinExtended-B", "[\\x{0180}-\\x{024F}]"},
+        {"IPAExtensions", "[\\x{0250}-\\x{02AF}]"},
+        {"SpacingModifierLetters", "[\\x{02B0}-\\x{02FF}]"},
+        {"CombiningDiacriticalMarks", "[\\x{0300}-\\x{036F}]"},
+        {"Greek", "[\\x{0370}-\\x{03FF}]"},
+        {"Cyrillic", "[\\x{0400}-\\x{04FF}]"},
+        {"Armenian", "[\\x{0530}-\\x{058F}]"},
+        {"Hebrew", "[\\x{0590}-\\x{05FF}]"},
+        {"Arabic", "[\\x{0600}-\\x{06FF}]"},
+        {"Syriac", "[\\x{0700}-\\x{074F}]"},
+        {"Thaana", "[\\x{0780}-\\x{07BF}]"},
+        {"Devanagari", "[\\x{0900}-\\x{097F}]"},
+        {"Bengali", "[\\x{0980}-\\x{09FF}]"},
+        {"Gurmukhi", "[\\x{0A00}-\\x{0A7F}]"},
+        {"Gujarati", "[\\x{0A80}-\\x{0AFF}]"},
+        {"Oriya", "[\\x{0B00}-\\x{0B7F}]"},
+        {"Tamil", "[\\x{0B80}-\\x{0BFF}]"},
+        {"Telugu", "[\\x{0C00}-\\x{0C7F}]"},
+        {"Kannada", "[\\x{0C80}-\\x{0CFF}]"},
+        {"Malayalam", "[\\x{0D00}-\\x{0D7F}]"},
+        {"Sinhala", "[\\x{0D80}-\\x{0DFF}]"},
+        {"Thai", "[\\x{0E00}-\\x{0E7F}]"},
+        {"Lao", "[\\x{0E80}-\\x{0EFF}]"},
+        {"Tibetan", "[\\x{0F00}-\\x{0FFF}]"},
+        {"Myanmar", "[\\x{1000}-\\x{109F}]"},
+        {"Georgian", "[\\x{10A0}-\\x{10FF}]"},
+        {"HangulJamo", "[\\x{1100}-\\x{11FF}]"},
+        {"Ethiopic", "[\\x{1200}-\\x{137F}]"},
+        {"Cherokee", "[\\x{13A0}-\\x{13FF}]"},
+        {"UnifiedCanadianAboriginalSyllabics", "[\\x{1400}-\\x{167F}]"},
+        {"Ogham", "[\\x{1680}-\\x{169F}]"},
+        {"Runic", "[\\x{16A0}-\\x{16FF}]"},
+        {"Khmer", "[\\x{1780}-\\x{17FF}]"},
+        {"Mongolian", "[\\x{1800}-\\x{18AF}]"},
+        {"LatinExtendedAdditional", "[\\x{1E00}-\\x{1EFF}]"},
+        {"GreekExtended", "[\\x{1F00}-\\x{1FFF}]"},
+        {"GeneralPunctuation", "[\\x{2000}-\\x{206F}]"},
+        {"SuperscriptsandSubscripts", "[\\x{2070}-\\x{209F}]"},
+        {"CurrencySymbols", "[\\x{20A0}-\\x{20CF}]"},
+        {"CombiningMarksforSymbols", "[\\x{20D0}-\\x{20FF}]"},
+        {"LetterlikeSymbols", "[\\x{2100}-\\x{214F}]"},
+        {"NumberForms", "[\\x{2150}-\\x{218F}]"},
+        {"Arrows", "[\\x{2190}-\\x{21FF}]"},
+        {"MathematicalOperators", "[\\x{2200}-\\x{22FF}]"},
+        {"MiscellaneousTechnical", "[\\x{2300}-\\x{23FF}]"},
+        {"ControlPictures", "[\\x{2400}-\\x{243F}]"},
+        {"OpticalCharacterRecognition", "[\\x{2440}-\\x{245F}]"},
+        {"EnclosedAlphanumerics", "[\\x{2460}-\\x{24FF}]"},
+        {"BoxDrawing", "[\\x{2500}-\\x{257F}]"},
+        {"BlockElements", "[\\x{2580}-\\x{259F}]"},
+        {"GeometricShapes", "[\\x{25A0}-\\x{25FF}]"},
+        {"MiscellaneousSymbols", "[\\x{2600}-\\x{26FF}]"},
+        {"Dingbats", "[\\x{2700}-\\x{27BF}]"},
+        {"BraillePatterns", "[\\x{2800}-\\x{28FF}]"},
+        {"CJKRadicalsSupplement", "[\\x{2E80}-\\x{2EFF}]"},
+        {"KangxiRadicals", "[\\x{2F00}-\\x{2FDF}]"},
+        {"IdeographicDescriptionCharacters", "[\\x{2FF0}-\\x{2FFF}]"},
+        {"CJKSymbolsandPunctuation", "[\\x{3000}-\\x{303F}]"},
+        {"Hiragana", "[\\x{3040}-\\x{309F}]"},
+        {"Katakana", "[\\x{30A0}-\\x{30FF}]"},
+        {"Bopomofo", "[\\x{3100}-\\x{312F}]"},
+        {"HangulCompatibilityJamo", "[\\x{3130}-\\x{318F}]"},
+        {"Kanbun", "[\\x{3190}-\\x{319F}]"},
+        {"BopomofoExtended", "[\\x{31A0}-\\x{31BF}]"},
+        {"EnclosedCJKLettersandMonths", "[\\x{3200}-\\x{32FF}]"},
+        {"CJKCompatibility", "[\\x{3300}-\\x{33FF}]"},
+        {"CJKUnifiedIdeographsExtensionA", "[\\x{3400}-\\x{4DB5}]"},
+        {"CJKUnifiedIdeographs", "[\\x{4E00}-\\x{9FFF}]"},
+        {"YiSyllables", "[\\x{A000}-\\x{A48F}]"},
+        {"YiRadicals", "[\\x{A490}-\\x{A4CF}]"},
+        {"HangulSyllables", "[\\x{AC00}-\\x{D7A3}]"},
+        {"PrivateUse", "[\\x{E000}-\\x{F8FF}]"},
+        {"CJKCompatibilityIdeographs", "[\\x{F900}-\\x{FAFF}]"},
+        {"AlphabeticPresentationForms", "[\\x{FB00}-\\x{FB4F}]"},
+        {"ArabicPresentationForms-A", "[\\x{FB50}-\\x{FDFF}]"},
+        {"CombiningHalfMarks", "[\\x{FE20}-\\x{FE2F}]"},
+        {"CJKCompatibilityForms", "[\\x{FE30}-\\x{FE4F}]"},
+        {"SmallFormVariants", "[\\x{FE50}-\\x{FE6F}]"},
+        {"ArabicPresentationForms-B", "[\\x{FE70}-\\x{FEFE}]"},
+        {"HalfwidthandFullwidthForms", "[\\x{FF00}-\\x{FFEF}]"},
+        {NULL, NULL}
+    };
+
+    /* adjust the expression to a Perl equivalent
+     * http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#regexs */
+
+    /* we need to replace all "$" with "\$", count them now */
+    for (count = 0, ptr = strpbrk(pattern, "^$"); ptr; ++count, ptr = strpbrk(ptr + 1, "^$"));
+
+    perl_regex = malloc((strlen(pattern) + 4 + count) * sizeof(char));
+    LY_CHECK_ERR_RET(!perl_regex, LOGMEM(ctx->ctx), LY_EMEM);
+    perl_regex[0] = '\0';
+
+    ptr = perl_regex;
+
+    if (strncmp(pattern + strlen(pattern) - 2, ".*", 2)) {
+        /* we will add line-end anchoring */
+        ptr[0] = '(';
+        ++ptr;
+    }
+
+    for (orig_ptr = pattern; orig_ptr[0]; ++orig_ptr) {
+        if (orig_ptr[0] == '$') {
+            ptr += sprintf(ptr, "\\$");
+        } else if (orig_ptr[0] == '^') {
+            ptr += sprintf(ptr, "\\^");
+        } else {
+            ptr[0] = orig_ptr[0];
+            ++ptr;
+        }
+    }
+
+    if (strncmp(pattern + strlen(pattern) - 2, ".*", 2)) {
+        ptr += sprintf(ptr, ")$");
+    } else {
+        ptr[0] = '\0';
+        ++ptr;
+    }
+
+    /* substitute Unicode Character Blocks with exact Character Ranges */
+    while ((ptr = strstr(perl_regex, "\\p{Is"))) {
+        start = ptr - perl_regex;
+
+        ptr = strchr(ptr, '}');
+        if (!ptr) {
+            LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LY_VCODE_INREGEXP,
+                   pattern, perl_regex + start + 2, "unterminated character property");
+            free(perl_regex);
+            return LY_EVALID;
+        }
+        end = (ptr - perl_regex) + 1;
+
+        /* need more space */
+        if (end - start < URANGE_LEN) {
+            perl_regex = ly_realloc(perl_regex, strlen(perl_regex) + (URANGE_LEN - (end - start)) + 1);
+            LY_CHECK_ERR_RET(!perl_regex, LOGMEM(ctx->ctx); free(perl_regex), LY_EMEM);
+        }
+
+        /* find our range */
+        for (idx = 0; ublock2urange[idx][0]; ++idx) {
+            if (!strncmp(perl_regex + start + 5, ublock2urange[idx][0], strlen(ublock2urange[idx][0]))) {
+                break;
+            }
+        }
+        if (!ublock2urange[idx][0]) {
+            LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LY_VCODE_INREGEXP,
+                   pattern, perl_regex + start + 5, "unknown block name");
+            free(perl_regex);
+            return LY_EVALID;
+        }
+
+        /* make the space in the string and replace the block (but we cannot include brackets if it was already enclosed in them) */
+        for (idx2 = 0, count = 0; idx2 < start; ++idx2) {
+            if ((perl_regex[idx2] == '[') && (!idx2 || (perl_regex[idx2 - 1] != '\\'))) {
+                ++count;
+            }
+            if ((perl_regex[idx2] == ']') && (!idx2 || (perl_regex[idx2 - 1] != '\\'))) {
+                --count;
+            }
+        }
+        if (count) {
+            /* skip brackets */
+            memmove(perl_regex + start + (URANGE_LEN - 2), perl_regex + end, strlen(perl_regex + end) + 1);
+            memcpy(perl_regex + start, ublock2urange[idx][1] + 1, URANGE_LEN - 2);
+        } else {
+            memmove(perl_regex + start + URANGE_LEN, perl_regex + end, strlen(perl_regex + end) + 1);
+            memcpy(perl_regex + start, ublock2urange[idx][1], URANGE_LEN);
+        }
+    }
+
+    /* must return 0, already checked during parsing */
+    precomp = pcre_compile(perl_regex, PCRE_UTF8 | PCRE_ANCHORED | PCRE_DOLLAR_ENDONLY | PCRE_NO_AUTO_CAPTURE,
+                           &err_msg, &err_offset, NULL);
+    if (!precomp) {
+        LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LY_VCODE_INREGEXP, pattern, perl_regex + err_offset, err_msg);
+        free(perl_regex);
+        return LY_EVALID;
+    }
+    free(perl_regex);
+
+    if (pcre_precomp) {
+        *pcre_precomp = precomp;
+    } else {
+        free(precomp);
+    }
+
+    return LY_SUCCESS;
+
+#undef URANGE_LEN
+}
+
+static LY_ERR
+lys_compile_type_patterns(struct lysc_ctx *ctx, struct lysp_restr *patterns_p, int options,
+                          struct lysc_pattern **base_patterns, struct lysc_pattern ***patterns)
+{
+    struct lysc_pattern **pattern;
+    unsigned int u, v;
+    const char *err_msg;
+    LY_ERR ret = LY_SUCCESS;
+
+    /* first, copy the patterns from the base type */
+    if (base_patterns) {
+        *patterns = lysc_patterns_dup(ctx->ctx, base_patterns);
+        LY_CHECK_ERR_RET(!(*patterns), LOGMEM(ctx->ctx), LY_EMEM);
+    }
+
+    LY_ARRAY_FOR(patterns_p, u) {
+        LY_ARRAY_NEW_RET(ctx->ctx, (*patterns), pattern, LY_EMEM);
+        *pattern = calloc(1, sizeof **pattern);
+        ++(*pattern)->refcount;
+
+        ret = lys_compile_type_pattern_check(ctx, &patterns_p[u].arg[1], &(*pattern)->expr);
+        LY_CHECK_RET(ret);
+        (*pattern)->expr_extra = pcre_study((*pattern)->expr, 0, &err_msg);
+        if (err_msg) {
+            LOGWRN(ctx->ctx, "Studying pattern \"%s\" failed (%s).", pattern, err_msg);
+        }
+
+        if (patterns_p[u].arg[0] == 0x15) {
+            (*pattern)->inverted = 1;
+        }
+        DUP_STRING(ctx->ctx, patterns_p[u].eapptag, (*pattern)->eapptag);
+        DUP_STRING(ctx->ctx, patterns_p[u].emsg, (*pattern)->emsg);
+        COMPILE_ARRAY_GOTO(ctx, patterns_p[u].exts, (*pattern)->exts,
+                           options, v, lys_compile_ext, ret, done);
+    }
+done:
+    return ret;
+}
+
+static uint16_t type_substmt_map[LY_DATA_TYPE_COUNT] = {
+    0 /* LY_TYPE_UNKNOWN */,
+    LYS_SET_LENGTH /* LY_TYPE_BINARY */,
+    LYS_SET_BIT /* LY_TYPE_BITS */,
+    0 /* LY_TYPE_BOOL */,
+    LYS_SET_FRDIGITS | LYS_SET_RANGE /* LY_TYPE_DEC64 */,
+    0 /* LY_TYPE_EMPTY */,
+    LYS_SET_ENUM /* LY_TYPE_ENUM */,
+    LYS_SET_BASE /* LY_TYPE_IDENT */,
+    LYS_SET_REQINST /* LY_TYPE_INST */,
+    LYS_SET_REQINST | LYS_SET_PATH /* LY_TYPE_LEAFREF */,
+    LYS_SET_LENGTH | LYS_SET_PATTERN /* LY_TYPE_STRING */,
+    LYS_SET_TYPE /* LY_TYPE_UNION */,
+    LYS_SET_RANGE /* LY_TYPE_INT8 */,
+    LYS_SET_RANGE /* LY_TYPE_UINT8 */,
+    LYS_SET_RANGE /* LY_TYPE_INT16 */,
+    LYS_SET_RANGE /* LY_TYPE_UINT16 */,
+    LYS_SET_RANGE /* LY_TYPE_INT32 */,
+    LYS_SET_RANGE /* LY_TYPE_UINT32 */,
+    LYS_SET_RANGE /* LY_TYPE_INT64 */,
+    LYS_SET_RANGE /* LY_TYPE_UINT64 */
+};
+
+static LY_ERR
+lys_compile_type_enums(struct lysc_ctx *ctx, struct lysp_type_enum *enums_p, LY_DATA_TYPE basetype, int options,
+                       struct lysc_type_enum_item *base_enums, struct lysc_type_enum_item **enums)
+{
+    LY_ERR ret = LY_SUCCESS;
+    unsigned int u, v, match;
+    int32_t value = 0;
+    uint32_t position = 0;
+    struct lysc_type_enum_item *e, storage;
+
+    if (base_enums && ctx->mod->compiled->version < 2) {
+        LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG, "%s type can be subtyped only in YANG 1.1 modules.",
+               basetype == LY_TYPE_ENUM ? "Enumeration" : "Bits");
+        return LY_EVALID;
+    }
+
+    LY_ARRAY_FOR(enums_p, u) {
+        LY_ARRAY_NEW_RET(ctx->ctx, *enums, e, LY_EMEM);
+        DUP_STRING(ctx->ctx, enums_p[u].name, e->name);
+        if (base_enums) {
+            /* check the enum/bit presence in the base type - the set of enums/bits in the derived type must be a subset */
+            LY_ARRAY_FOR(base_enums, v) {
+                if (!strcmp(e->name, base_enums[v].name)) {
+                    break;
+                }
+            }
+            if (v == LY_ARRAY_SIZE(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);
+                return LY_EVALID;
+            }
+            match = v;
+        }
+
+        if (basetype == LY_TYPE_ENUM) {
+            if (enums_p[u].flags & LYS_SET_VALUE) {
+                e->value = (int32_t)enums_p[u].value;
+                if (!u || e->value >= value) {
+                    value = e->value + 1;
+                }
+                /* check collision with other values */
+                for (v = 0; v < LY_ARRAY_SIZE(*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\".",
+                               e->value, e->name, (*enums)[v].name);
+                        return LY_EVALID;
+                    }
+                }
+            } else if (base_enums) {
+                /* inherit the assigned value */
+                e->value = base_enums[match].value;
+                if (!u || e->value >= value) {
+                    value = e->value + 1;
+                }
+            } else {
+                /* assign value automatically */
+                if (u && value == INT32_MIN) {
+                    /* counter overflow */
+                    LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
+                           "Invalid enumeration - it is not possible to auto-assign enum value for "
+                           "\"%s\" since the highest value is already 2147483647.", e->name);
+                    return LY_EVALID;
+                }
+                e->value = value++;
+            }
+        } else { /* LY_TYPE_BITS */
+            if (enums_p[u].flags & LYS_SET_VALUE) {
+                e->value = (int32_t)enums_p[u].value;
+                if (!u || (uint32_t)e->value >= position) {
+                    position = (uint32_t)e->value + 1;
+                }
+                /* check collision with other values */
+                for (v = 0; v < LY_ARRAY_SIZE(*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\".",
+                               (uint32_t)e->value, e->name, (*enums)[v].name);
+                        return LY_EVALID;
+                    }
+                }
+            } else if (base_enums) {
+                /* inherit the assigned value */
+                e->value = base_enums[match].value;
+                if (!u || (uint32_t)e->value >= position) {
+                    position = (uint32_t)e->value + 1;
+                }
+            } else {
+                /* assign value automatically */
+                if (u && position == 0) {
+                    /* counter overflow */
+                    LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
+                           "Invalid bits - it is not possible to auto-assign bit position for "
+                           "\"%s\" since the highest value is already 4294967295.", e->name);
+                    return LY_EVALID;
+                }
+                e->value = position++;
+            }
+        }
+
+        if (base_enums) {
+            /* the assigned values must not change from the derived type */
+            if (e->value != base_enums[match].value) {
+                if (basetype == LY_TYPE_ENUM) {
+                    LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
+                       "Invalid enumeration - value of the item \"%s\" has changed from %d to %d in the derived type.",
+                       e->name, base_enums[match].value, e->value);
+                } else {
+                    LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
+                       "Invalid bits - position of the item \"%s\" has changed from %u to %u in the derived type.",
+                       e->name, (uint32_t)base_enums[match].value, (uint32_t)e->value);
+                }
+                return LY_EVALID;
+            }
+        }
+
+        COMPILE_ARRAY_GOTO(ctx, enums_p[u].iffeatures, e->iffeatures, options, v, lys_compile_iffeature, ret, done);
+        COMPILE_ARRAY_GOTO(ctx, enums_p[u].exts, e->exts, options, v, lys_compile_ext, ret, done);
+
+        if (basetype == LY_TYPE_BITS) {
+            /* keep bits ordered by position */
+            for (v = u; v && (*enums)[v - 1].value > e->value; --v);
+            if (v != u) {
+                memcpy(&storage, e, sizeof *e);
+                memmove(&(*enums)[v + 1], &(*enums)[v], (u - v) * sizeof **enums);
+                memcpy(&(*enums)[v], &storage, sizeof storage);
+            }
+        }
+    }
+
+done:
+    return ret;
+}
+
+static LY_ERR
+lys_compile_type(struct lysc_ctx *ctx, struct lysp_node_leaf *leaf_p, int options, struct lysc_type **type)
+{
+    LY_ERR ret = LY_SUCCESS;
+    unsigned int u;
+    struct lysp_type *type_p = &leaf_p->type;
+    struct type_context {
+        const struct lysp_tpdf *tpdf;
+        struct lysp_node *node;
+        struct lysp_module *mod;
+    } *tctx, *tctx_prev = NULL;
+    LY_DATA_TYPE basetype = LY_TYPE_UNKNOWN;
+    struct lysc_type *base = NULL;
+    struct ly_set tpdf_chain = {0};
+    struct lysc_type_bin *bin;
+    struct lysc_type_num *num;
+    struct lysc_type_str *str;
+    struct lysc_type_bits *bits;
+    struct lysc_type_enum *enumeration;
+
+    (*type) = NULL;
+
+    tctx = calloc(1, sizeof *tctx);
+    LY_CHECK_ERR_RET(!tctx, LOGMEM(ctx->ctx), LY_EMEM);
+    for (ret = lysp_type_find(type_p->name, (struct lysp_node*)leaf_p, ctx->mod->parsed,
+                             &basetype, &tctx->tpdf, &tctx->node, &tctx->mod);
+            ret == LY_SUCCESS;
+            ret = lysp_type_find(tctx_prev->tpdf->type.name, tctx_prev->node, tctx_prev->mod,
+                                         &basetype, &tctx->tpdf, &tctx->node, &tctx->mod)) {
+        if (basetype) {
+            break;
+        }
+
+        /* check status */
+        ret = lysc_check_status(ctx, leaf_p->flags, ctx->mod->parsed, leaf_p->name,
+                                tctx->tpdf->flags, tctx->mod, tctx->node ? tctx->node->name : tctx->mod->name);
+        LY_CHECK_ERR_GOTO(ret,  free(tctx), cleanup);
+
+        if (tctx->tpdf->type.compiled) {
+            /* it is not necessary to continue, the rest of the chain was already compiled */
+            basetype = tctx->tpdf->type.compiled->basetype;
+            ly_set_add(&tpdf_chain, tctx, LY_SET_OPT_USEASLIST);
+            tctx = NULL;
+            break;
+        }
+
+        /* store information for the following processing */
+        ly_set_add(&tpdf_chain, tctx, LY_SET_OPT_USEASLIST);
+
+        /* prepare next loop */
+        tctx_prev = tctx;
+        tctx = calloc(1, sizeof *tctx);
+        LY_CHECK_ERR_RET(!tctx, LOGMEM(ctx->ctx), LY_EMEM);
+    }
+    free(tctx);
+
+    /* allocate type according to the basetype */
+    switch (basetype) {
+    case LY_TYPE_BINARY:
+        *type = calloc(1, sizeof(struct lysc_type_bin));
+        bin = (struct lysc_type_bin*)(*type);
+        break;
+    case LY_TYPE_BITS:
+        *type = calloc(1, sizeof(struct lysc_type_bits));
+        bits = (struct lysc_type_bits*)(*type);
+        break;
+    case LY_TYPE_BOOL:
+    case LY_TYPE_EMPTY:
+        *type = calloc(1, sizeof(struct lysc_type));
+        break;
+    case LY_TYPE_DEC64:
+        *type = calloc(1, sizeof(struct lysc_type_dec));
+        break;
+    case LY_TYPE_ENUM:
+        *type = calloc(1, sizeof(struct lysc_type_enum));
+        enumeration = (struct lysc_type_enum*)(*type);
+        break;
+    case LY_TYPE_IDENT:
+        *type = calloc(1, sizeof(struct lysc_type_identityref));
+        break;
+    case LY_TYPE_INST:
+        *type = calloc(1, sizeof(struct lysc_type_instanceid));
+        break;
+    case LY_TYPE_LEAFREF:
+        *type = calloc(1, sizeof(struct lysc_type_leafref));
+        break;
+    case LY_TYPE_STRING:
+        *type = calloc(1, sizeof(struct lysc_type_str));
+        str = (struct lysc_type_str*)(*type);
+        break;
+    case LY_TYPE_UNION:
+        *type = calloc(1, sizeof(struct lysc_type_union));
+        break;
+    case LY_TYPE_INT8:
+    case LY_TYPE_UINT8:
+    case LY_TYPE_INT16:
+    case LY_TYPE_UINT16:
+    case LY_TYPE_INT32:
+    case LY_TYPE_UINT32:
+    case LY_TYPE_INT64:
+    case LY_TYPE_UINT64:
+        *type = calloc(1, sizeof(struct lysc_type_num));
+        num = (struct lysc_type_num*)(*type);
+        break;
+    case LY_TYPE_UNKNOWN:
+        LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_REFERENCE,
+               "Referenced type \"%s\" not found.", tctx_prev ? tctx_prev->tpdf->type.name : type_p->name);
+        ret = LY_EVALID;
+        goto cleanup;
+    }
+    LY_CHECK_ERR_GOTO(!(*type), LOGMEM(ctx->ctx), cleanup);
+    if (~type_substmt_map[basetype] & leaf_p->type.flags) {
+        LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG, "Invalid type restrictions for %s type.",
+               ly_data_type2str[basetype]);
+        free(*type);
+        (*type) = NULL;
+        ret = LY_EVALID;
+        goto cleanup;
+    }
+
+    /* get restrictions from the referred typedefs */
+    for (u = tpdf_chain.count - 1; u + 1 > 0; --u) {
+        tctx = (struct type_context*)tpdf_chain.objs[u];
+        if (~type_substmt_map[basetype] & tctx->tpdf->type.flags) {
+            LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG, "Invalid type \"%s\" restriction(s) for %s type.",
+                   tctx->tpdf->name, ly_data_type2str[basetype]);
+            ret = LY_EVALID;
+            goto cleanup;
+        } else if (tctx->tpdf->type.compiled) {
+            base = tctx->tpdf->type.compiled;
+            continue;
+        } else if ((u != tpdf_chain.count - 1) && !(tctx->tpdf->type.flags)) {
+            /* no change, just use the type information from the base */
+            base = ((struct lysp_tpdf*)tctx->tpdf)->type.compiled = ((struct type_context*)tpdf_chain.objs[u + 1])->tpdf->type.compiled;
+            ++base->refcount;
+            continue;
+        }
+
+        ++(*type)->refcount;
+        (*type)->basetype = basetype;
+        switch (basetype) {
+        case LY_TYPE_BINARY:
+            /* RFC 6020 9.8.1, 9.4.4 - length, number of octets it contains */
+            if (tctx->tpdf->type.length) {
+                ret = lys_compile_type_range(ctx, tctx->tpdf->type.length, basetype, 1,
+                                             base ? ((struct lysc_type_bin*)base)->length : NULL, &bin->length);
+                LY_CHECK_GOTO(ret, cleanup);
+            }
+
+            base = ((struct lysp_tpdf*)tctx->tpdf)->type.compiled = *type;
+            *type = calloc(1, sizeof(struct lysc_type_bin));
+            bin = (struct lysc_type_bin*)(*type);
+            break;
+        case LY_TYPE_BITS:
+            /* RFC 6020 9.6 - enum */
+            if (tctx->tpdf->type.bits) {
+                ret = lys_compile_type_enums(ctx, tctx->tpdf->type.bits, basetype, options,
+                                             base ? (struct lysc_type_enum_item*)((struct lysc_type_bits*)base)->bits : NULL,
+                                             (struct lysc_type_enum_item**)&bits->bits);
+                LY_CHECK_GOTO(ret, cleanup);
+            }
+
+            if ((u == tpdf_chain.count - 1) && !(tctx->tpdf->type.flags)) {
+                /* type derived from bits built-in type must contain at least one bit */
+                if (!bits->bits) {
+                    LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
+                           "Missing bit substatement for bits type \"%s\".", tctx->tpdf->name);
+                    ret = LY_EVALID;
+                    goto cleanup;
+                }
+            }
+
+            base = ((struct lysp_tpdf*)tctx->tpdf)->type.compiled = *type;
+            *type = calloc(1, sizeof(struct lysc_type_bits));
+            bits = (struct lysc_type_bits*)(*type);
+            break;
+        case LY_TYPE_STRING:
+            /* RFC 6020 9.4.4 - length */
+            if (tctx->tpdf->type.length) {
+                ret = lys_compile_type_range(ctx, tctx->tpdf->type.length, basetype, 1,
+                                             base ? ((struct lysc_type_str*)base)->length : NULL, &str->length);
+                LY_CHECK_GOTO(ret, cleanup);
+            } else if (base && ((struct lysc_type_str*)base)->length) {
+                str->length = lysc_range_dup(ctx->ctx, ((struct lysc_type_str*)base)->length);
+            }
+
+            /* RFC 6020 9.4.6 - pattern */
+            if (tctx->tpdf->type.patterns) {
+                ret = lys_compile_type_patterns(ctx, tctx->tpdf->type.patterns, options,
+                                                base ? ((struct lysc_type_str*)base)->patterns : NULL, &str->patterns);
+                LY_CHECK_GOTO(ret, cleanup);
+            } else if (base && ((struct lysc_type_str*)base)->patterns) {
+                str->patterns = lysc_patterns_dup(ctx->ctx, ((struct lysc_type_str*)base)->patterns);
+            }
+
+            base = ((struct lysp_tpdf*)tctx->tpdf)->type.compiled = *type;
+            *type = calloc(1, sizeof(struct lysc_type_str));
+            str = (struct lysc_type_str*)(*type);
+            break;
+        case LY_TYPE_ENUM:
+            /* RFC 6020 9.6 - enum */
+            if (tctx->tpdf->type.enums) {
+                ret = lys_compile_type_enums(ctx, tctx->tpdf->type.enums, basetype, options,
+                                             base ? ((struct lysc_type_enum*)base)->enums : NULL, &enumeration->enums);
+                LY_CHECK_GOTO(ret, cleanup);
+            }
+
+            if ((u == tpdf_chain.count - 1) && !(tctx->tpdf->type.flags)) {
+                /* type derived from enumerations built-in type must contain at least one enum */
+                if (!enumeration->enums) {
+                    LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
+                           "Missing enum substatement for enumeration type \"%s\".", tctx->tpdf->name);
+                    ret = LY_EVALID;
+                    goto cleanup;
+                }
+            }
+
+            base = ((struct lysp_tpdf*)tctx->tpdf)->type.compiled = *type;
+            *type = calloc(1, sizeof(struct lysc_type_enum));
+            enumeration = (struct lysc_type_enum*)(*type);
+            break;
+        case LY_TYPE_INT8:
+        case LY_TYPE_UINT8:
+        case LY_TYPE_INT16:
+        case LY_TYPE_UINT16:
+        case LY_TYPE_INT32:
+        case LY_TYPE_UINT32:
+        case LY_TYPE_INT64:
+        case LY_TYPE_UINT64:
+            /* RFC 6020 9.2.4 - range */
+            if (tctx->tpdf->type.range) {
+                ret = lys_compile_type_range(ctx, tctx->tpdf->type.range, basetype, 1,
+                                             base ? ((struct lysc_type_num*)base)->range : NULL, &num->range);
+                LY_CHECK_GOTO(ret, cleanup);
+            }
+
+            base = ((struct lysp_tpdf*)tctx->tpdf)->type.compiled = *type;
+            *type = calloc(1, sizeof(struct lysc_type_num));
+            num = (struct lysc_type_num*)(*type);
+            break;
+        case LY_TYPE_BOOL:
+        case LY_TYPE_EMPTY:
+        case LY_TYPE_UNKNOWN: /* just to complete switch */
+            base = ((struct lysp_tpdf*)tctx->tpdf)->type.compiled = *type;
+            *type = calloc(1, sizeof(struct lysc_type));
+            break;
+        }
+        LY_CHECK_ERR_GOTO(!(*type), LOGMEM(ctx->ctx); ret = LY_EMEM, cleanup);
+
+    }
+
+    if (leaf_p->type.flags) {
+        /* get restrictions from the node itself, finalize the type structure */
+        (*type)->basetype = basetype;
+        ++(*type)->refcount;
+        switch (basetype) {
+        case LY_TYPE_BINARY:
+            if (leaf_p->type.length) {
+                ret = lys_compile_type_range(ctx, leaf_p->type.length, basetype, 1,
+                                             base ? ((struct lysc_type_bin*)base)->length : NULL, &bin->length);
+                LY_CHECK_GOTO(ret, cleanup);
+                COMPILE_ARRAY_GOTO(ctx, leaf_p->type.length->exts, bin->length->exts,
+                                   options, u, lys_compile_ext, ret, cleanup);
+            }
+            break;
+        case LY_TYPE_BITS:
+            if (leaf_p->type.bits) {
+                ret = lys_compile_type_enums(ctx, leaf_p->type.bits, basetype, options,
+                                             base ? (struct lysc_type_enum_item*)((struct lysc_type_bits*)base)->bits : NULL,
+                                             (struct lysc_type_enum_item**)&bits->bits);
+                LY_CHECK_GOTO(ret, cleanup);
+            }
+            break;
+        case LY_TYPE_STRING:
+            if (leaf_p->type.length) {
+                ret = lys_compile_type_range(ctx, leaf_p->type.length, basetype, 1,
+                                             base ? ((struct lysc_type_str*)base)->length : NULL, &str->length);
+                LY_CHECK_GOTO(ret, cleanup);
+                COMPILE_ARRAY_GOTO(ctx, leaf_p->type.length->exts, str->length->exts,
+                                   options, u, lys_compile_ext, ret, cleanup);
+            } else if (base && ((struct lysc_type_str*)base)->length) {
+                str->length = lysc_range_dup(ctx->ctx, ((struct lysc_type_str*)base)->length);
+            }
+
+            if (leaf_p->type.patterns) {
+                ret = lys_compile_type_patterns(ctx, leaf_p->type.patterns, options,
+                                                base ? ((struct lysc_type_str*)base)->patterns : NULL, &str->patterns);
+                LY_CHECK_GOTO(ret, cleanup);
+            } else if (base && ((struct lysc_type_str*)base)->patterns) {
+                str->patterns = lysc_patterns_dup(ctx->ctx, ((struct lysc_type_str*)base)->patterns);
+            }
+            break;
+        case LY_TYPE_ENUM:
+            if (leaf_p->type.enums) {
+                ret = lys_compile_type_enums(ctx, leaf_p->type.enums, basetype, options,
+                                             base ? ((struct lysc_type_enum*)base)->enums : NULL, &enumeration->enums);
+                LY_CHECK_GOTO(ret, cleanup);
+            }
+            break;
+        case LY_TYPE_INT8:
+        case LY_TYPE_UINT8:
+        case LY_TYPE_INT16:
+        case LY_TYPE_UINT16:
+        case LY_TYPE_INT32:
+        case LY_TYPE_UINT32:
+        case LY_TYPE_INT64:
+        case LY_TYPE_UINT64:
+            if (leaf_p->type.range) {
+                ret = lys_compile_type_range(ctx, leaf_p->type.range, basetype, 0,
+                                             base ? ((struct lysc_type_num*)base)->range : NULL, &num->range);
+                LY_CHECK_GOTO(ret, cleanup);
+                COMPILE_ARRAY_GOTO(ctx, leaf_p->type.range->exts, num->range->exts,
+                                   options, u, lys_compile_ext, ret, cleanup);
+            }
+            break;
+        case LY_TYPE_BOOL:
+        case LY_TYPE_EMPTY:
+        case LY_TYPE_UNKNOWN: /* just to complete switch */
+            /* nothing to do */
+            break;
+        }
+    } else if (base) {
+        /* no specific restriction in leaf's type definition, copy from the base */
+        free(*type);
+        (*type) = base;
+        ++(*type)->refcount;
+    } else {
+        /* there are some limitations on types derived directly from built-in types */
+        if (basetype == LY_TYPE_BITS) {
+            if (!bits->bits) {
+                LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
+                       "Missing bit substatement for bits type.");
+                free(*type);
+                *type = NULL;
+                ret = LY_EVALID;
+                goto cleanup;
+            }
+        } else if (basetype == LY_TYPE_ENUM) {
+            if (!enumeration->enums) {
+                LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SYNTAX_YANG,
+                       "Missing enum substatement for enumeration type.");
+                free(*type);
+                *type = NULL;
+                ret = LY_EVALID;
+                goto cleanup;
+            }
+        }
+    }
+
+    COMPILE_ARRAY_GOTO(ctx, type_p->exts, (*type)->exts, options, u, lys_compile_ext, ret, cleanup);
+
+cleanup:
+    ly_set_erase(&tpdf_chain, free);
+    return ret;
+}
+
+static LY_ERR lys_compile_node(struct lysc_ctx *ctx, struct lysp_node *node_p, int options, struct lysc_node *parent);
+
+static LY_ERR
+lys_compile_node_container(struct lysc_ctx *ctx, struct lysp_node *node_p, int options, struct lysc_node *node)
+{
+    struct lysp_node_container *cont_p = (struct lysp_node_container*)node_p;
+    struct lysc_node_container *cont = (struct lysc_node_container*)node;
+    struct lysp_node *child_p;
+    unsigned int u;
+    LY_ERR ret = LY_SUCCESS;
+
+    COMPILE_MEMBER_GOTO(ctx, cont_p->when, cont->when, options, lys_compile_when, ret, done);
+    COMPILE_ARRAY_GOTO(ctx, cont_p->iffeatures, cont->iffeatures, options, u, lys_compile_iffeature, ret, done);
+
+    LY_LIST_FOR(cont_p->child, child_p) {
+        LY_CHECK_RET(lys_compile_node(ctx, child_p, options, node));
+    }
+
+    COMPILE_ARRAY_GOTO(ctx, cont_p->musts, cont->musts, options, u, lys_compile_must, ret, done);
+    //COMPILE_ARRAY_GOTO(ctx, cont_p->actions, cont->actions, options, u, lys_compile_action, ret, done);
+    //COMPILE_ARRAY_GOTO(ctx, cont_p->notifs, cont->notifs, options, u, lys_compile_notif, ret, done);
+
+done:
+    return ret;
+}
+
+static LY_ERR
+lys_compile_node_leaf(struct lysc_ctx *ctx, struct lysp_node *node_p, int options, struct lysc_node *node)
+{
+    struct lysp_node_leaf *leaf_p = (struct lysp_node_leaf*)node_p;
+    struct lysc_node_leaf *leaf = (struct lysc_node_leaf*)node;
+    unsigned int u;
+    LY_ERR ret = LY_SUCCESS;
+
+    COMPILE_MEMBER_GOTO(ctx, leaf_p->when, leaf->when, options, lys_compile_when, ret, done);
+    COMPILE_ARRAY_GOTO(ctx, leaf_p->iffeatures, leaf->iffeatures, options, u, lys_compile_iffeature, ret, done);
+
+    COMPILE_ARRAY_GOTO(ctx, leaf_p->musts, leaf->musts, options, u, lys_compile_must, ret, done);
+    ret = lys_compile_type(ctx, leaf_p, options, &leaf->type);
+    LY_CHECK_GOTO(ret, done);
+
+    DUP_STRING(ctx->ctx, leaf_p->units, leaf->units);
+    DUP_STRING(ctx->ctx, leaf_p->dflt, leaf->dflt);
+done:
+    return ret;
+}
+
+static LY_ERR
+lys_compile_node(struct lysc_ctx *ctx, struct lysp_node *node_p, int options, struct lysc_node *parent)
+{
+    LY_ERR ret = LY_EVALID;
+    struct lysc_node *node, **children;
+    unsigned int u;
+    LY_ERR (*node_compile_spec)(struct lysc_ctx*, struct lysp_node*, int, struct lysc_node*);
+
+    switch (node_p->nodetype) {
+    case LYS_CONTAINER:
+        node = (struct lysc_node*)calloc(1, sizeof(struct lysc_node_container));
+        node_compile_spec = lys_compile_node_container;
+        break;
+    case LYS_LEAF:
+        node = (struct lysc_node*)calloc(1, sizeof(struct lysc_node_leaf));
+        node_compile_spec = lys_compile_node_leaf;
+        break;
+    case LYS_LIST:
+        node = (struct lysc_node*)calloc(1, sizeof(struct lysc_node_list));
+        break;
+    case LYS_LEAFLIST:
+        node = (struct lysc_node*)calloc(1, sizeof(struct lysc_node_leaflist));
+        break;
+    case LYS_CASE:
+        node = (struct lysc_node*)calloc(1, sizeof(struct lysc_node_case));
+        break;
+    case LYS_CHOICE:
+        node = (struct lysc_node*)calloc(1, sizeof(struct lysc_node_choice));
+        break;
+    case LYS_USES:
+        node = (struct lysc_node*)calloc(1, sizeof(struct lysc_node_uses));
+        break;
+    case LYS_ANYXML:
+    case LYS_ANYDATA:
+        node = (struct lysc_node*)calloc(1, sizeof(struct lysc_node_anydata));
+        break;
+    default:
+        LOGINT(ctx->ctx);
+        return LY_EINT;
+    }
+    LY_CHECK_ERR_RET(!node, LOGMEM(ctx->ctx), LY_EMEM);
+    node->nodetype = node_p->nodetype;
+    node->module = ctx->mod;
+    node->prev = node;
+    node->flags = node_p->flags;
+
+    /* config */
+    if (!(node->flags & LYS_CONFIG_MASK)) {
+        /* config not explicitely set, inherit it from parent */
+        if (parent) {
+            node->flags |= parent->flags & LYS_CONFIG_MASK;
+        } else {
+            /* default is config true */
+            node->flags |= LYS_CONFIG_W;
+        }
+    }
+
+    /* status - it is not inherited by specification, but it does not make sense to have
+     * current in deprecated or deprecated in obsolete, so we do print warning and inherit status */
+    if (!(node->flags & LYS_STATUS_MASK)) {
+        if (parent && (parent->flags & (LYS_STATUS_DEPRC | LYS_STATUS_OBSLT))) {
+            LOGWRN(ctx->ctx, "Missing explicit \"%s\" status that was already specified in parent, inheriting.",
+                   (parent->flags & LYS_STATUS_DEPRC) ? "deprecated" : "obsolete");
+            node->flags |= parent->flags & LYS_STATUS_MASK;
+        } else {
+            node->flags |= LYS_STATUS_CURR;
+        }
+    } else if (parent) {
+        /* check status compatibility with the parent */
+        if ((parent->flags & LYS_STATUS_MASK) > (node->flags & LYS_STATUS_MASK)) {
+            if (node->flags & LYS_STATUS_CURR) {
+                LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
+                       "A \"current\" status is in conflict with the parent's \"%s\" status.",
+                       (parent->flags & LYS_STATUS_DEPRC) ? "deprecated" : "obsolete");
+            } else { /* LYS_STATUS_DEPRC */
+                LOGVAL(ctx->ctx, LY_VLOG_STR, ctx->path, LYVE_SEMANTICS,
+                       "A \"deprecated\" status is in conflict with the parent's \"obsolete\" status.");
+            }
+            goto error;
+        }
+    }
+
+    if (!(options & LYSC_OPT_FREE_SP)) {
+        node->sp = node_p;
+    }
+    DUP_STRING(ctx->ctx, node_p->name, node->name);
+    COMPILE_ARRAY_GOTO(ctx, node_p->exts, node->exts, options, u, lys_compile_ext, ret, error);
+
+    /* nodetype-specific part */
+    LY_CHECK_GOTO(node_compile_spec(ctx, node_p, options, node), error);
+
+    /* insert into parent's children */
+    if (parent && (children = lysc_node_children(parent))) {
+        if (!(*children)) {
+            /* first child */
+            *children = node;
+        } else {
+            /* insert at the end of the parent's children list */
+            (*children)->prev->next = node;
+            node->prev = (*children)->prev;
+            (*children)->prev = node;
+        }
+    } else {
+        /* top-level element */
+        if (!ctx->mod->compiled->data) {
+            ctx->mod->compiled->data = node;
+        } else {
+            /* insert at the end of the module's top-level nodes list */
+            ctx->mod->compiled->data->prev->next = node;
+            node->prev = ctx->mod->compiled->data->prev;
+            ctx->mod->compiled->data->prev = node;
+        }
+    }
+
+    return LY_SUCCESS;
+
+error:
+    lysc_node_free(ctx->ctx, node);
+    return ret;
+}
+
+LY_ERR
+lys_compile(struct lys_module *mod, int options)
+{
+    struct lysc_ctx ctx = {0};
+    struct lysc_module *mod_c;
+    struct lysp_module *sp;
+    struct lysp_node *node_p;
+    unsigned int u;
+    LY_ERR ret;
+
+    LY_CHECK_ARG_RET(NULL, mod, mod->parsed, mod->parsed->ctx, LY_EINVAL);
+    sp = mod->parsed;
+
+    if (sp->submodule) {
+        LOGERR(sp->ctx, LY_EINVAL, "Submodules (%s) are not supposed to be compiled, compile only the main modules.", sp->name);
+        return LY_EINVAL;
+    }
+
+    ctx.ctx = sp->ctx;
+    ctx.mod = mod;
+
+    mod->compiled = mod_c = calloc(1, sizeof *mod_c);
+    LY_CHECK_ERR_RET(!mod_c, LOGMEM(sp->ctx), LY_EMEM);
+    mod_c->ctx = sp->ctx;
+    mod_c->implemented = sp->implemented;
+    mod_c->latest_revision = sp->latest_revision;
+    mod_c->version = sp->version;
+
+    DUP_STRING(sp->ctx, sp->name, mod_c->name);
+    DUP_STRING(sp->ctx, sp->ns, mod_c->ns);
+    DUP_STRING(sp->ctx, sp->prefix, mod_c->prefix);
+    if (sp->revs) {
+        DUP_STRING(sp->ctx, sp->revs[0].date, mod_c->revision);
+    }
+    COMPILE_ARRAY_GOTO(&ctx, sp->imports, mod_c->imports, options, u, lys_compile_import, ret, error);
+    COMPILE_ARRAY_GOTO(&ctx, sp->features, mod_c->features, options, u, lys_compile_feature, ret, error);
+    COMPILE_ARRAY_GOTO(&ctx, sp->identities, mod_c->identities, options, u, lys_compile_identity, ret, error);
+    if (sp->identities) {
+        LY_CHECK_RET(lys_compile_identities_derived(&ctx, sp->identities, mod_c->identities));
+    }
+
+    LY_LIST_FOR(sp->data, node_p) {
+        ret = lys_compile_node(&ctx, node_p, options, NULL);
+        LY_CHECK_GOTO(ret, error);
+    }
+    //COMPILE_ARRAY_GOTO(ctx, sp->rpcs, mod_c->rpcs, options, u, lys_compile_action, ret, error);
+    //COMPILE_ARRAY_GOTO(ctx, sp->notifs, mod_c->notifs, options, u, lys_compile_notif, ret, error);
+
+    COMPILE_ARRAY_GOTO(&ctx, sp->exts, mod_c->exts, options, u, lys_compile_ext, ret, error);
+
+    if (options & LYSC_OPT_FREE_SP) {
+        lysp_module_free(mod->parsed);
+        ((struct lys_module*)mod)->parsed = NULL;
+    }
+
+    ((struct lys_module*)mod)->compiled = mod_c;
+    return LY_SUCCESS;
+
+error:
+    lysc_module_free(mod_c, NULL);
+    ((struct lys_module*)mod)->compiled = NULL;
+    return ret;
+}
diff --git a/src/tree_schema_free.c b/src/tree_schema_free.c
new file mode 100644
index 0000000..deb227c
--- /dev/null
+++ b/src/tree_schema_free.c
@@ -0,0 +1,646 @@
+/**
+ * @file tree_schema.c
+ * @author Radek Krejci <rkrejci@cesnet.cz>
+ * @brief Schema tree implementation
+ *
+ * Copyright (c) 2015 - 2018 CESNET, z.s.p.o.
+ *
+ * This source code is licensed under BSD 3-Clause License (the "License").
+ * You may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     https://opensource.org/licenses/BSD-3-Clause
+ */
+
+#include "common.h"
+
+#include <ctype.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <linux/limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "libyang.h"
+#include "context.h"
+#include "tree_schema_internal.h"
+#include "xpath.h"
+
+#define FREE_ARRAY(CTX, ARRAY, FUNC) {uint64_t c__; LY_ARRAY_FOR(ARRAY, c__){FUNC(CTX, &(ARRAY)[c__]);}LY_ARRAY_FREE(ARRAY);}
+#define FREE_MEMBER(CTX, MEMBER, FUNC) if (MEMBER) {FUNC(CTX, MEMBER);free(MEMBER);}
+#define FREE_STRING(CTX, STRING) if (STRING) {lydict_remove(CTX, STRING);}
+#define FREE_STRINGS(CTX, ARRAY) {uint64_t c__; LY_ARRAY_FOR(ARRAY, c__){FREE_STRING(CTX, ARRAY[c__]);}LY_ARRAY_FREE(ARRAY);}
+
+static void lysp_grp_free(struct ly_ctx *ctx, struct lysp_grp *grp);
+static void lysp_node_free(struct ly_ctx *ctx, struct lysp_node *node);
+
+static void
+lysp_stmt_free(struct ly_ctx *ctx, struct lysp_stmt *stmt)
+{
+    struct lysp_stmt *child, *next;
+
+    FREE_STRING(ctx, stmt->stmt);
+    FREE_STRING(ctx, stmt->arg);
+
+    LY_LIST_FOR_SAFE(stmt->child, next, child) {
+        lysp_stmt_free(ctx, child);
+    }
+
+    free(stmt);
+}
+
+static void
+lysp_ext_instance_free(struct ly_ctx *ctx, struct lysp_ext_instance *ext)
+{
+    struct lysp_stmt *stmt, *next;
+
+    FREE_STRING(ctx, ext->name);
+    FREE_STRING(ctx, ext->argument);
+
+    LY_LIST_FOR_SAFE(ext->child, next, stmt) {
+        lysp_stmt_free(ctx, stmt);
+    }
+}
+
+static void
+lysp_import_free(struct ly_ctx *ctx, struct lysp_import *import)
+{
+    /* imported module is freed directly from the context's list */
+    FREE_STRING(ctx, import->name);
+    FREE_STRING(ctx, import->prefix);
+    FREE_STRING(ctx, import->dsc);
+    FREE_STRING(ctx, import->ref);
+    FREE_ARRAY(ctx, import->exts, lysp_ext_instance_free);
+}
+
+static void
+lysp_include_free(struct ly_ctx *ctx, struct lysp_include *include)
+{
+    if (include->submodule) {
+        lysp_module_free(include->submodule);
+    }
+    FREE_STRING(ctx, include->name);
+    FREE_STRING(ctx, include->dsc);
+    FREE_STRING(ctx, include->ref);
+    FREE_ARRAY(ctx, include->exts, lysp_ext_instance_free);
+}
+
+static void
+lysp_revision_free(struct ly_ctx *ctx, struct lysp_revision *rev)
+{
+    FREE_STRING(ctx, rev->dsc);
+    FREE_STRING(ctx, rev->ref);
+    FREE_ARRAY(ctx, rev->exts, lysp_ext_instance_free);
+}
+
+static void
+lysp_ext_free(struct ly_ctx *ctx, struct lysp_ext *ext)
+{
+    FREE_STRING(ctx, ext->name);
+    FREE_STRING(ctx, ext->argument);
+    FREE_STRING(ctx, ext->dsc);
+    FREE_STRING(ctx, ext->ref);
+    FREE_ARRAY(ctx, ext->exts, lysp_ext_instance_free);
+}
+
+static void
+lysp_feature_free(struct ly_ctx *ctx, struct lysp_feature *feat)
+{
+    FREE_STRING(ctx, feat->name);
+    FREE_STRINGS(ctx, feat->iffeatures);
+    FREE_STRING(ctx, feat->dsc);
+    FREE_STRING(ctx, feat->ref);
+    FREE_ARRAY(ctx, feat->exts, lysp_ext_instance_free);
+}
+
+static void
+lysp_ident_free(struct ly_ctx *ctx, struct lysp_ident *ident)
+{
+    FREE_STRING(ctx, ident->name);
+    FREE_STRINGS(ctx, ident->iffeatures);
+    FREE_STRINGS(ctx, ident->bases);
+    FREE_STRING(ctx, ident->dsc);
+    FREE_STRING(ctx, ident->ref);
+    FREE_ARRAY(ctx, ident->exts, lysp_ext_instance_free);
+}
+
+static void
+lysp_restr_free(struct ly_ctx *ctx, struct lysp_restr *restr)
+{
+    FREE_STRING(ctx, restr->arg);
+    FREE_STRING(ctx, restr->emsg);
+    FREE_STRING(ctx, restr->eapptag);
+    FREE_STRING(ctx, restr->dsc);
+    FREE_STRING(ctx, restr->ref);
+    FREE_ARRAY(ctx, restr->exts, lysp_ext_instance_free);
+}
+
+static void
+lysp_type_enum_free(struct ly_ctx *ctx, struct lysp_type_enum *item)
+{
+    FREE_STRING(ctx, item->name);
+    FREE_STRING(ctx, item->dsc);
+    FREE_STRING(ctx, item->ref);
+    FREE_STRINGS(ctx, item->iffeatures);
+    FREE_ARRAY(ctx, item->exts, lysp_ext_instance_free);
+}
+
+static void lysc_type_free(struct ly_ctx *ctx, struct lysc_type *type);
+static void
+lysp_type_free(struct ly_ctx *ctx, struct lysp_type *type)
+{
+    FREE_STRING(ctx, type->name);
+    FREE_MEMBER(ctx, type->range, lysp_restr_free);
+    FREE_MEMBER(ctx, type->length, lysp_restr_free);
+    FREE_ARRAY(ctx, type->patterns, lysp_restr_free);
+    FREE_ARRAY(ctx, type->enums, lysp_type_enum_free);
+    FREE_ARRAY(ctx, type->bits, lysp_type_enum_free);
+    FREE_STRING(ctx, type->path);
+    FREE_STRINGS(ctx, type->bases);
+    FREE_ARRAY(ctx, type->types, lysp_type_free);
+    FREE_ARRAY(ctx, type->exts, lysp_ext_instance_free);
+    if (type->compiled) {
+        lysc_type_free(ctx, type->compiled);
+    }
+}
+
+static void
+lysp_tpdf_free(struct ly_ctx *ctx, struct lysp_tpdf *tpdf)
+{
+    FREE_STRING(ctx, tpdf->name);
+    FREE_STRING(ctx, tpdf->units);
+    FREE_STRING(ctx, tpdf->dflt);
+    FREE_STRING(ctx, tpdf->dsc);
+    FREE_STRING(ctx, tpdf->ref);
+    FREE_ARRAY(ctx, tpdf->exts, lysp_ext_instance_free);
+
+    lysp_type_free(ctx, &tpdf->type);
+
+}
+
+static void
+lysp_action_inout_free(struct ly_ctx *ctx, struct lysp_action_inout *inout)
+{
+    struct lysp_node *node, *next;
+
+    FREE_ARRAY(ctx, inout->musts, lysp_restr_free);
+    FREE_ARRAY(ctx, inout->typedefs, lysp_tpdf_free);
+    FREE_ARRAY(ctx, inout->groupings, lysp_grp_free);
+    LY_LIST_FOR_SAFE(inout->data, next, node) {
+        lysp_node_free(ctx, node);
+    }
+    FREE_ARRAY(ctx, inout->exts, lysp_ext_instance_free);
+
+}
+
+static void
+lysp_action_free(struct ly_ctx *ctx, struct lysp_action *action)
+{
+    FREE_STRING(ctx, action->name);
+    FREE_STRING(ctx, action->dsc);
+    FREE_STRING(ctx, action->ref);
+    FREE_STRINGS(ctx, action->iffeatures);
+    FREE_ARRAY(ctx, action->typedefs, lysp_tpdf_free);
+    FREE_ARRAY(ctx, action->groupings, lysp_grp_free);
+    FREE_MEMBER(ctx, action->input, lysp_action_inout_free);
+    FREE_MEMBER(ctx, action->output, lysp_action_inout_free);
+    FREE_ARRAY(ctx, action->exts, lysp_ext_instance_free);
+}
+
+static void
+lysp_notif_free(struct ly_ctx *ctx, struct lysp_notif *notif)
+{
+    struct lysp_node *node, *next;
+
+    FREE_STRING(ctx, notif->name);
+    FREE_STRING(ctx, notif->dsc);
+    FREE_STRING(ctx, notif->ref);
+    FREE_STRINGS(ctx, notif->iffeatures);
+    FREE_ARRAY(ctx, notif->musts, lysp_restr_free);
+    FREE_ARRAY(ctx, notif->typedefs, lysp_tpdf_free);
+    FREE_ARRAY(ctx, notif->groupings, lysp_grp_free);
+    LY_LIST_FOR_SAFE(notif->data, next, node) {
+        lysp_node_free(ctx, node);
+    }
+    FREE_ARRAY(ctx, notif->exts, lysp_ext_instance_free);
+}
+
+static void
+lysp_grp_free(struct ly_ctx *ctx, struct lysp_grp *grp)
+{
+    struct lysp_node *node, *next;
+
+    FREE_STRING(ctx, grp->name);
+    FREE_STRING(ctx, grp->dsc);
+    FREE_STRING(ctx, grp->ref);
+    FREE_ARRAY(ctx, grp->typedefs, lysp_tpdf_free);
+    FREE_ARRAY(ctx, grp->groupings, lysp_grp_free);
+    LY_LIST_FOR_SAFE(grp->data, next, node) {
+        lysp_node_free(ctx, node);
+    }
+    FREE_ARRAY(ctx, grp->actions, lysp_action_free);
+    FREE_ARRAY(ctx, grp->notifs, lysp_notif_free);
+    FREE_ARRAY(ctx, grp->exts, lysp_ext_instance_free);
+}
+
+static void
+lysp_when_free(struct ly_ctx *ctx, struct lysp_when *when)
+{
+    FREE_STRING(ctx, when->cond);
+    FREE_STRING(ctx, when->dsc);
+    FREE_STRING(ctx, when->ref);
+    FREE_ARRAY(ctx, when->exts, lysp_ext_instance_free);
+}
+
+static void
+lysp_augment_free(struct ly_ctx *ctx, struct lysp_augment *augment)
+{
+    struct lysp_node *node, *next;
+
+    FREE_STRING(ctx, augment->nodeid);
+    FREE_STRING(ctx, augment->dsc);
+    FREE_STRING(ctx, augment->ref);
+    FREE_MEMBER(ctx, augment->when, lysp_when_free);
+    FREE_STRINGS(ctx, augment->iffeatures);
+    LY_LIST_FOR_SAFE(augment->child, next, node) {
+        lysp_node_free(ctx, node);
+    }
+    FREE_ARRAY(ctx, augment->actions, lysp_action_free);
+    FREE_ARRAY(ctx, augment->notifs, lysp_notif_free);
+    FREE_ARRAY(ctx, augment->exts, lysp_ext_instance_free);
+}
+
+static void
+lysp_deviate_free(struct ly_ctx *ctx, struct lysp_deviate *d)
+{
+    struct lysp_deviate_add *add = (struct lysp_deviate_add*)d;
+    struct lysp_deviate_rpl *rpl = (struct lysp_deviate_rpl*)d;
+
+    FREE_ARRAY(ctx, d->exts, lysp_ext_instance_free);
+    switch(d->mod) {
+    case LYS_DEV_NOT_SUPPORTED:
+        /* nothing to do */
+        break;
+    case LYS_DEV_ADD:
+    case LYS_DEV_DELETE: /* compatible for dynamically allocated data */
+        FREE_STRING(ctx, add->units);
+        FREE_ARRAY(ctx, add->musts, lysp_restr_free);
+        FREE_STRINGS(ctx, add->uniques);
+        FREE_STRINGS(ctx, add->dflts);
+        break;
+    case LYS_DEV_REPLACE:
+        FREE_MEMBER(ctx, rpl->type, lysp_type_free);
+        FREE_STRING(ctx, rpl->units);
+        FREE_STRING(ctx, rpl->dflt);
+        break;
+    default:
+        LOGINT(ctx);
+        break;
+    }
+}
+
+static void
+lysp_deviation_free(struct ly_ctx *ctx, struct lysp_deviation *dev)
+{
+    struct lysp_deviate *next, *iter;
+
+    FREE_STRING(ctx, dev->nodeid);
+    FREE_STRING(ctx, dev->dsc);
+    FREE_STRING(ctx, dev->ref);
+    LY_LIST_FOR_SAFE(dev->deviates, next, iter) {
+        lysp_deviate_free(ctx, iter);
+        free(iter);
+    }
+    FREE_ARRAY(ctx, dev->exts, lysp_ext_instance_free);
+}
+
+static void
+lysp_refine_free(struct ly_ctx *ctx, struct lysp_refine *ref)
+{
+    FREE_STRING(ctx, ref->nodeid);
+    FREE_STRING(ctx, ref->dsc);
+    FREE_STRING(ctx, ref->ref);
+    FREE_STRINGS(ctx, ref->iffeatures);
+    FREE_ARRAY(ctx, ref->musts, lysp_restr_free);
+    FREE_STRING(ctx, ref->presence);
+    FREE_STRINGS(ctx, ref->dflts);
+    FREE_ARRAY(ctx, ref->exts, lysp_ext_instance_free);
+}
+
+static void
+lysp_node_free(struct ly_ctx *ctx, struct lysp_node *node)
+{
+    struct lysp_node *child, *next;
+
+    FREE_STRING(ctx, node->name);
+    FREE_STRING(ctx, node->dsc);
+    FREE_STRING(ctx, node->ref);
+    FREE_MEMBER(ctx, node->when, lysp_when_free);
+    FREE_STRINGS(ctx, node->iffeatures);
+    FREE_ARRAY(ctx, node->exts, lysp_ext_instance_free);
+
+    switch(node->nodetype) {
+    case LYS_CONTAINER:
+        FREE_ARRAY(ctx, ((struct lysp_node_container*)node)->musts, lysp_restr_free);
+        FREE_STRING(ctx, ((struct lysp_node_container*)node)->presence);
+        FREE_ARRAY(ctx, ((struct lysp_node_container*)node)->typedefs, lysp_tpdf_free);
+        FREE_ARRAY(ctx, ((struct lysp_node_container*)node)->groupings, lysp_grp_free);
+        LY_LIST_FOR_SAFE(((struct lysp_node_container*)node)->child, next, child) {
+            lysp_node_free(ctx, child);
+        }
+        FREE_ARRAY(ctx, ((struct lysp_node_container*)node)->actions, lysp_action_free);
+        FREE_ARRAY(ctx, ((struct lysp_node_container*)node)->notifs, lysp_notif_free);
+        break;
+    case LYS_LEAF:
+        FREE_ARRAY(ctx, ((struct lysp_node_leaf*)node)->musts, lysp_restr_free);
+        lysp_type_free(ctx, &((struct lysp_node_leaf*)node)->type);
+        FREE_STRING(ctx, ((struct lysp_node_leaf*)node)->units);
+        FREE_STRING(ctx, ((struct lysp_node_leaf*)node)->dflt);
+        break;
+    case LYS_LEAFLIST:
+        FREE_ARRAY(ctx, ((struct lysp_node_leaflist*)node)->musts, lysp_restr_free);
+        lysp_type_free(ctx, &((struct lysp_node_leaflist*)node)->type);
+        FREE_STRING(ctx, ((struct lysp_node_leaflist*)node)->units);
+        FREE_STRINGS(ctx, ((struct lysp_node_leaflist*)node)->dflts);
+        break;
+    case LYS_LIST:
+        FREE_ARRAY(ctx, ((struct lysp_node_list*)node)->musts, lysp_restr_free);
+        FREE_STRING(ctx, ((struct lysp_node_list*)node)->key);
+        FREE_ARRAY(ctx, ((struct lysp_node_list*)node)->typedefs, lysp_tpdf_free);
+        FREE_ARRAY(ctx, ((struct lysp_node_list*)node)->groupings,  lysp_grp_free);
+        LY_LIST_FOR_SAFE(((struct lysp_node_list*)node)->child, next, child) {
+            lysp_node_free(ctx, child);
+        }
+        FREE_ARRAY(ctx, ((struct lysp_node_list*)node)->actions, lysp_action_free);
+        FREE_ARRAY(ctx, ((struct lysp_node_list*)node)->notifs, lysp_notif_free);
+        FREE_STRINGS(ctx, ((struct lysp_node_list*)node)->uniques);
+        break;
+    case LYS_CHOICE:
+        LY_LIST_FOR_SAFE(((struct lysp_node_choice*)node)->child, next, child) {
+            lysp_node_free(ctx, child);
+        }
+        FREE_STRING(ctx, ((struct lysp_node_choice*)node)->dflt);
+        break;
+    case LYS_CASE:
+        LY_LIST_FOR_SAFE(((struct lysp_node_case*)node)->child, next, child) {
+            lysp_node_free(ctx, child);
+        }
+        break;
+    case LYS_ANYDATA:
+    case LYS_ANYXML:
+        FREE_ARRAY(ctx, ((struct lysp_node_anydata*)node)->musts, lysp_restr_free);
+        break;
+    case LYS_USES:
+        FREE_ARRAY(ctx, ((struct lysp_node_uses*)node)->refines, lysp_refine_free);
+        FREE_ARRAY(ctx, ((struct lysp_node_uses*)node)->augments, lysp_augment_free);
+        break;
+    default:
+        LOGINT(ctx);
+    }
+
+    free(node);
+}
+
+API void
+lysp_module_free(struct lysp_module *module)
+{
+    struct ly_ctx *ctx;
+    struct lysp_node *node, *next;
+
+    LY_CHECK_ARG_RET(NULL, module,);
+    ctx = module->ctx;
+
+    FREE_STRING(ctx, module->name);
+    FREE_STRING(ctx, module->filepath);
+    FREE_STRING(ctx, module->ns);  /* or belongs-to */
+    FREE_STRING(ctx, module->prefix);
+
+    FREE_ARRAY(ctx, module->imports, lysp_import_free);
+    FREE_ARRAY(ctx, module->includes, lysp_include_free);
+
+    FREE_STRING(ctx, module->org);
+    FREE_STRING(ctx, module->contact);
+    FREE_STRING(ctx, module->dsc);
+    FREE_STRING(ctx, module->ref);
+
+    FREE_ARRAY(ctx, module->revs, lysp_revision_free);
+    FREE_ARRAY(ctx, module->extensions, lysp_ext_free);
+    FREE_ARRAY(ctx, module->features, lysp_feature_free);
+    FREE_ARRAY(ctx, module->identities, lysp_ident_free);
+    FREE_ARRAY(ctx, module->typedefs, lysp_tpdf_free);
+    FREE_ARRAY(ctx, module->groupings, lysp_grp_free);
+    LY_LIST_FOR_SAFE(module->data, next, node) {
+        lysp_node_free(ctx, node);
+    }
+    FREE_ARRAY(ctx, module->augments, lysp_augment_free);
+    FREE_ARRAY(ctx, module->rpcs, lysp_action_free);
+    FREE_ARRAY(ctx, module->notifs, lysp_notif_free);
+    FREE_ARRAY(ctx, module->deviations, lysp_deviation_free);
+    FREE_ARRAY(ctx, module->exts, lysp_ext_instance_free);
+
+    free(module);
+}
+
+static void
+lysc_ext_instance_free(struct ly_ctx *ctx, struct lysc_ext_instance *ext)
+{
+    FREE_STRING(ctx, ext->argument);
+    FREE_ARRAY(ctx, ext->exts, lysc_ext_instance_free);
+}
+
+static void
+lysc_iffeature_free(struct ly_ctx *UNUSED(ctx), struct lysc_iffeature *iff)
+{
+    LY_ARRAY_FREE(iff->features);
+    free(iff->expr);
+}
+
+static void
+lysc_import_free(struct ly_ctx *ctx, struct lysc_import *import)
+{
+    /* imported module is freed directly from the context's list */
+    FREE_STRING(ctx, import->prefix);
+    FREE_ARRAY(ctx, import->exts, lysc_ext_instance_free);
+}
+
+static void
+lysc_ident_free(struct ly_ctx *ctx, struct lysc_ident *ident)
+{
+    FREE_STRING(ctx, ident->name);
+    FREE_ARRAY(ctx, ident->iffeatures, lysc_iffeature_free);
+    LY_ARRAY_FREE(ident->derived);
+    FREE_ARRAY(ctx, ident->exts, lysc_ext_instance_free);
+}
+
+static void
+lysc_feature_free(struct ly_ctx *ctx, struct lysc_feature *feat)
+{
+    FREE_STRING(ctx, feat->name);
+    FREE_ARRAY(ctx, feat->iffeatures, lysc_iffeature_free);
+    LY_ARRAY_FREE(feat->depfeatures);
+    FREE_ARRAY(ctx, feat->exts, lysc_ext_instance_free);
+}
+
+static void
+lysc_range_free(struct ly_ctx *ctx, struct lysc_range *range)
+{
+    LY_ARRAY_FREE(range->parts);
+    FREE_STRING(ctx, range->eapptag);
+    FREE_STRING(ctx, range->emsg);
+    FREE_ARRAY(ctx, range->exts, lysc_ext_instance_free);
+}
+
+static void
+lysc_pattern_free(struct ly_ctx *ctx, struct lysc_pattern **pattern)
+{
+    if (--(*pattern)->refcount) {
+        return;
+    }
+    pcre_free((*pattern)->expr);
+    pcre_free_study((*pattern)->expr_extra);
+    FREE_STRING(ctx, (*pattern)->eapptag);
+    FREE_STRING(ctx, (*pattern)->emsg);
+    FREE_ARRAY(ctx, (*pattern)->exts, lysc_ext_instance_free);
+    free(*pattern);
+}
+
+static void
+lysc_enum_item_free(struct ly_ctx *ctx, struct lysc_type_enum_item *item)
+{
+    FREE_STRING(ctx, item->name);
+    FREE_ARRAY(ctx, item->iffeatures, lysc_iffeature_free);
+    FREE_ARRAY(ctx, item->exts, lysc_ext_instance_free);
+}
+
+static void
+lysc_type_free(struct ly_ctx *ctx, struct lysc_type *type)
+{
+    if (--type->refcount) {
+        return;
+    }
+    switch(type->basetype) {
+    case LY_TYPE_BINARY:
+        FREE_MEMBER(ctx, ((struct lysc_type_bin*)type)->length, lysc_range_free);
+        break;
+    case LY_TYPE_BITS:
+        FREE_ARRAY(ctx, (struct lysc_type_enum_item*)((struct lysc_type_bits*)type)->bits, lysc_enum_item_free);
+        break;
+    case LY_TYPE_STRING:
+        FREE_MEMBER(ctx, ((struct lysc_type_str*)type)->length, lysc_range_free);
+        FREE_ARRAY(ctx, ((struct lysc_type_str*)type)->patterns, lysc_pattern_free);
+        break;
+    case LY_TYPE_ENUM:
+        FREE_ARRAY(ctx, ((struct lysc_type_enum*)type)->enums, lysc_enum_item_free);
+        break;
+    case LY_TYPE_INT8:
+    case LY_TYPE_UINT8:
+    case LY_TYPE_INT16:
+    case LY_TYPE_UINT16:
+    case LY_TYPE_INT32:
+    case LY_TYPE_UINT32:
+    case LY_TYPE_INT64:
+    case LY_TYPE_UINT64:
+        FREE_MEMBER(ctx, ((struct lysc_type_num*)type)->range, lysc_range_free);
+        break;
+    case LY_TYPE_BOOL:
+    case LY_TYPE_EMPTY:
+    case LY_TYPE_UNKNOWN: /* just to complete switch */
+        /* nothing to do */
+        break;
+    }
+    FREE_ARRAY(ctx, type->exts, lysc_ext_instance_free);
+
+    free(type);
+}
+
+void
+lysc_node_container_free(struct ly_ctx *ctx, struct lysc_node_container *node)
+{
+    struct lysc_node *child, *child_next;
+
+    LY_LIST_FOR_SAFE(node->child, child_next, child) {
+        lysc_node_free(ctx, child);
+    }
+}
+
+static void
+lysc_node_leaf_free(struct ly_ctx *ctx, struct lysc_node_leaf *node)
+{
+    if (node->type) {
+        lysc_type_free(ctx, node->type);
+    }
+}
+
+void
+lysc_node_free(struct ly_ctx *ctx, struct lysc_node *node)
+{
+    /* common part */
+    FREE_STRING(ctx, node->name);
+
+    /* nodetype-specific part */
+    switch(node->nodetype) {
+    case LYS_CONTAINER:
+        lysc_node_container_free(ctx, (struct lysc_node_container*)node);
+        break;
+    case LYS_LEAF:
+        lysc_node_leaf_free(ctx, (struct lysc_node_leaf*)node);
+        break;
+    default:
+        LOGINT(ctx);
+    }
+
+    free(node);
+}
+
+static void
+lysc_module_free_(struct lysc_module *module)
+{
+    struct ly_ctx *ctx;
+    struct lysc_node *node, *node_next;
+
+    LY_CHECK_ARG_RET(NULL, module,);
+    ctx = module->ctx;
+
+    FREE_STRING(ctx, module->name);
+    FREE_STRING(ctx, module->ns);
+    FREE_STRING(ctx, module->prefix);
+    FREE_STRING(ctx, module->revision);
+
+    FREE_ARRAY(ctx, module->imports, lysc_import_free);
+    FREE_ARRAY(ctx, module->features, lysc_feature_free);
+    FREE_ARRAY(ctx, module->identities, lysc_ident_free);
+
+    LY_LIST_FOR_SAFE(module->data, node_next, node) {
+        lysc_node_free(ctx, node);
+    }
+
+    FREE_ARRAY(ctx, module->exts, lysc_ext_instance_free);
+
+    free(module);
+}
+
+void
+lysc_module_free(struct lysc_module *module, void (*private_destructor)(const struct lysc_node *node, void *priv))
+{
+    (void) private_destructor;
+
+    if (module) {
+        lysc_module_free_(module);
+    }
+}
+
+void
+lys_module_free(struct lys_module *module, void (*private_destructor)(const struct lysc_node *node, void *priv))
+{
+    if (!module) {
+        return;
+    }
+
+    lysc_module_free(module->compiled, private_destructor);
+    lysp_module_free(module->parsed);
+    free(module);
+}
diff --git a/src/tree_schema_internal.h b/src/tree_schema_internal.h
index 24fbc9b..1ca6d4c 100644
--- a/src/tree_schema_internal.h
+++ b/src/tree_schema_internal.h
@@ -321,6 +321,20 @@
 void lys_module_implement(struct lys_module *mod);
 
 /**
+ * @brief Free the compiled node structure.
+ * @param[in] ctx libyang context where the string data resides in a dictionary.
+ * @param[in,out] node Compiled node structure to be freed.
+ */
+void lysc_node_free(struct ly_ctx *ctx, struct lysc_node *node);
+
+/**
+ * @brief Free the compiled schema structure.
+ * @param[in,out] module Compiled schema module structure to free.
+ * @param[in] private_destructor Function to remove private data from the compiled schema tree.
+ */
+void lysc_module_free(struct lysc_module *module, void (*private_destructor)(const struct lysc_node *node, void *priv));
+
+/**
  * @brief Free the schema structure. It just frees, it does not remove the schema from its context.
  * @param[in,out] module Schema module structure to free.
  * @param[in] private_destructor Function to remove private data from the compiled schema tree.
diff --git a/tests/src/test_context.c b/tests/src/test_context.c
index cc5adfa..d7c75fb 100644
--- a/tests/src/test_context.c
+++ b/tests/src/test_context.c
@@ -21,6 +21,8 @@
 #include "../../src/parser_yang.c"
 #include "../../src/context.c"
 #include "../../src/tree_schema_helpers.c"
+#include "../../src/tree_schema_free.c"
+#include "../../src/tree_schema_compile.c"
 #include "../../src/tree_schema.c"
 
 #include <stdarg.h>
diff --git a/tests/src/test_hash_table.c b/tests/src/test_hash_table.c
index 7411206..2f10f0a 100644
--- a/tests/src/test_hash_table.c
+++ b/tests/src/test_hash_table.c
@@ -23,6 +23,8 @@
 #include "../../src/parser_yang.c"
 #include "../../src/context.c"
 #include "../../src/tree_schema_helpers.c"
+#include "../../src/tree_schema_free.c"
+#include "../../src/tree_schema_compile.c"
 #include "../../src/tree_schema.c"
 
 #include <stdarg.h>
diff --git a/tests/src/test_parser_yang.c b/tests/src/test_parser_yang.c
index 23144dc..9ebfbec 100644
--- a/tests/src/test_parser_yang.c
+++ b/tests/src/test_parser_yang.c
@@ -20,6 +20,8 @@
 #include "../../src/parser_yang.c"
 #include "../../src/context.c"
 #include "../../src/tree_schema_helpers.c"
+#include "../../src/tree_schema_free.c"
+#include "../../src/tree_schema_compile.c"
 #include "../../src/tree_schema.c"
 
 #include <stdarg.h>
diff --git a/tests/src/test_tree_schema_compile.c b/tests/src/test_tree_schema_compile.c
index a0d5cd1..bc4169c 100644
--- a/tests/src/test_tree_schema_compile.c
+++ b/tests/src/test_tree_schema_compile.c
@@ -18,6 +18,8 @@
 #include "../../src/xpath.c"
 #include "../../src/parser_yang.c"
 #include "../../src/tree_schema_helpers.c"
+#include "../../src/tree_schema_free.c"
+#include "../../src/tree_schema_compile.c"
 #include "../../src/tree_schema.c"
 #include "../../src/context.c"
 #include "../../src/hash_table.c"
diff --git a/tests/src/test_tree_schema_helpers.c b/tests/src/test_tree_schema_helpers.c
index 580d488..29b7e8c 100644
--- a/tests/src/test_tree_schema_helpers.c
+++ b/tests/src/test_tree_schema_helpers.c
@@ -17,6 +17,7 @@
 #include "../../src/set.c"
 #include "../../src/parser_yang.c"
 #include "../../src/tree_schema.c"
+#include "../../src/tree_schema_free.c"
 #include "../../src/tree_schema_helpers.c"
 #include "../../src/hash_table.c"
 #include "../../src/xpath.c"
