diff --git a/src/parser_yin.c b/src/parser_yin.c
index 2712fe1..b20877e 100644
--- a/src/parser_yin.c
+++ b/src/parser_yin.c
@@ -3,7 +3,7 @@
  * @author Radek Krejci <rkrejci@cesnet.cz>
  * @brief YIN parser for libyang
  *
- * Copyright (c) 2015 CESNET, z.s.p.o.
+ * 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.
@@ -32,25 +32,25 @@
 #include "tree_internal.h"
 #include "xml_internal.h"
 
-#define GETVAL(value, node, arg)                                                 \
+#define GETVAL(ctx, value, node, arg)                                                 \
     value = lyxml_get_attr(node, arg, NULL);                                     \
     if (!value) {                                                                \
-        LOGVAL(LYE_MISSARG, LY_VLOG_NONE, NULL, arg, node->name);                \
+        LOGVAL(ctx, LYE_MISSARG, LY_VLOG_NONE, NULL, arg, node->name);                \
         goto error;                                                              \
     }
 
-#define YIN_CHECK_ARRAY_OVERFLOW_CODE(counter, storage, name, parent, code)      \
+#define YIN_CHECK_ARRAY_OVERFLOW_CODE(ctx, counter, storage, name, parent, code)      \
     if ((counter) == LY_ARRAY_MAX(storage)) {                                    \
-        LOGERR(LY_EINT, "Reached limit (%"PRIu64") for storing %s in %s statement.", \
+        LOGERR(ctx, LY_EINT, "Reached limit (%"PRIu64") for storing %s in %s statement.", \
                LY_ARRAY_MAX(storage), name, parent);                             \
         code;                                                                    \
     }
 
-#define YIN_CHECK_ARRAY_OVERFLOW_RETURN(counter, storage, name, parent, retval)  \
-    YIN_CHECK_ARRAY_OVERFLOW_CODE(counter, storage, name, parent, return retval)
+#define YIN_CHECK_ARRAY_OVERFLOW_RETURN(ctx, counter, storage, name, parent, retval)  \
+    YIN_CHECK_ARRAY_OVERFLOW_CODE(ctx, counter, storage, name, parent, return retval)
 
-#define YIN_CHECK_ARRAY_OVERFLOW_GOTO(counter, storage, name, parent, target)    \
-    YIN_CHECK_ARRAY_OVERFLOW_CODE(counter, storage, name, parent, goto target)
+#define YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, counter, storage, name, parent, target)    \
+    YIN_CHECK_ARRAY_OVERFLOW_CODE(ctx, counter, storage, name, parent, goto target)
 
 #define OPT_IDENT       0x01
 #define OPT_CFG_PARSE   0x02
@@ -96,7 +96,7 @@
     struct unres_ext *info;
 
     info = malloc(sizeof *info);
-    LY_CHECK_ERR_RETURN(!info, LOGMEM, EXIT_FAILURE);
+    LY_CHECK_ERR_RETURN(!info, LOGMEM(module->ctx), EXIT_FAILURE);
     lyxml_unlink(module->ctx, yin);
     info->data.yin = yin;
     info->datatype = LYS_IN_YIN;
@@ -122,8 +122,8 @@
 
     /* there should be <text> child */
     if (!node->child || !node->child->name || strcmp(node->child->name, name)) {
-        LOGERR(LY_EVALID, "Expected \"%s\" element in \"%s\" element.", name, node->name);
-        LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, name, node->name);
+        LOGERR(ctx, LY_EVALID, "Expected \"%s\" element in \"%s\" element.", name, node->name);
+        LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, name, node->name);
         return NULL;
     } else if (node->child->content) {
         len = strlen(node->child->content);
@@ -236,7 +236,7 @@
         statement = "deviation";
         break;
     default:
-        LOGERR(LY_EINT, "parent type %d", elem_type);
+        LOGERR(mod->ctx, LY_EINT, "parent type %d", elem_type);
         return EXIT_FAILURE;
     }
 
@@ -256,10 +256,10 @@
         /* parse it as extension */
 parseext:
 
-        YIN_CHECK_ARRAY_OVERFLOW_RETURN(*ext_size, *ext_size, "extension", statement, EXIT_FAILURE);
+        YIN_CHECK_ARRAY_OVERFLOW_RETURN(mod->ctx, *ext_size, *ext_size, "extension", statement, EXIT_FAILURE);
         /* first, allocate a space for the extension instance in the parent elem */
         reallocated = realloc(*ext, (1 + (*ext_size)) * sizeof **ext);
-        LY_CHECK_ERR_RETURN(!reallocated, LOGMEM, EXIT_FAILURE);
+        LY_CHECK_ERR_RETURN(!reallocated, LOGMEM(mod->ctx), EXIT_FAILURE);
         (*ext) = reallocated;
 
         /* init memory */
@@ -286,11 +286,12 @@
     int r, c_ext = 0;
     const char *value;
     struct lyxml_elem *node, *next;
+    struct ly_ctx *ctx = parent->module->ctx;
 
-    GETVAL(value, yin, "name");
+    GETVAL(ctx, value, yin, "name");
 
     if ((lys_node_module(parent)->version != 2) && ((value[0] == '(') || strchr(value, ' '))) {
-        LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, "if-feature");
+        LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, "if-feature");
 error:
         return EXIT_FAILURE;
     }
@@ -300,7 +301,7 @@
     }
 
     r = resolve_iffeature_compile(iffeat, value, parent, parent_is_feature, unres);
-    lydict_remove(parent->module->ctx, value);
+    lydict_remove(ctx, value);
     if (r) {
         return EXIT_FAILURE;
     }
@@ -308,19 +309,19 @@
     LY_TREE_FOR_SAFE(yin->child, next, node) {
         if (!node->ns) {
             /* garbage */
-            lyxml_free(parent->module->ctx, node);
+            lyxml_free(ctx, node);
         } else if (strcmp(node->ns->value, LY_NSYIN)) {
             /* extension */
-            YIN_CHECK_ARRAY_OVERFLOW_RETURN(c_ext, iffeat->ext_size, "extensions", "if-feature", EXIT_FAILURE);
+            YIN_CHECK_ARRAY_OVERFLOW_RETURN(ctx, c_ext, iffeat->ext_size, "extensions", "if-feature", EXIT_FAILURE);
             c_ext++;
         } else {
-            LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, node->name, "if-feature");
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->name, "if-feature");
             return EXIT_FAILURE;
         }
     }
     if (c_ext) {
         iffeat->ext = calloc(c_ext, sizeof *iffeat->ext);
-        LY_CHECK_ERR_RETURN(!iffeat->ext, LOGMEM, EXIT_FAILURE);
+        LY_CHECK_ERR_RETURN(!iffeat->ext, LOGMEM(ctx), EXIT_FAILURE);
         LY_TREE_FOR_SAFE(yin->child, next, node) {
             /* extensions */
             r = lyp_yin_fill_ext(iffeat, LYEXT_PAR_IDENT, 0, 0, parent->module, node,
@@ -340,12 +341,13 @@
 fill_yin_identity(struct lys_module *module, struct lyxml_elem *yin, struct lys_ident *ident, struct unres_schema *unres)
 {
     struct lyxml_elem *node, *next;
+    struct ly_ctx *ctx = module->ctx;
     const char *value;
     int rc;
     int c_ftrs = 0, c_base = 0, c_ext = 0;
     void *reallocated;
 
-    GETVAL(value, yin, "name");
+    GETVAL(ctx, value, yin, "name");
     ident->name = value;
 
     if (read_yin_common(module, NULL, ident, LYEXT_PAR_IDENT, yin, OPT_IDENT | OPT_MODULE, unres)) {
@@ -359,25 +361,25 @@
     LY_TREE_FOR(yin->child, node) {
         if (strcmp(node->ns->value, LY_NSYIN)) {
             /* extension */
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ext, ident->ext_size, "extensions", "identity", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ext, ident->ext_size, "extensions", "identity", error);
             c_ext++;
         } else if (!strcmp(node->name, "base")) {
             if (c_base && (module->version < 2)) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "base", "identity");
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, "base", "identity");
                 goto error;
             }
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_base, ident->base_size, "bases", "identity", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_base, ident->base_size, "bases", "identity", error);
             if (lyp_yin_parse_subnode_ext(module, ident, LYEXT_PAR_IDENT, node, LYEXT_SUBSTMT_BASE, c_base, unres)) {
                 goto error;
             }
             c_base++;
 
         } else if ((module->version >= 2) && !strcmp(node->name, "if-feature")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ftrs, ident->iffeature_size, "if-features", "identity", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ftrs, ident->iffeature_size, "if-features", "identity", error);
             c_ftrs++;
 
         } else {
-            LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, node->name, "identity");
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->name, "identity");
             goto error;
         }
     }
@@ -385,16 +387,16 @@
     if (c_base) {
         ident->base_size = 0;
         ident->base = calloc(c_base, sizeof *ident->base);
-        LY_CHECK_ERR_GOTO(!ident->base, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!ident->base, LOGMEM(ctx), error);
     }
     if (c_ftrs) {
         ident->iffeature = calloc(c_ftrs, sizeof *ident->iffeature);
-        LY_CHECK_ERR_GOTO(!ident->iffeature, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!ident->iffeature, LOGMEM(ctx), error);
     }
     if (c_ext) {
         /* some extensions may be already present from the substatements */
         reallocated = realloc(ident->ext, (c_ext + ident->ext_size) * sizeof *ident->ext);
-        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM(ctx), error);
         ident->ext = reallocated;
 
         /* init memory */
@@ -410,17 +412,17 @@
                 goto error;
             }
         } else if (!strcmp(node->name, "base")) {
-            GETVAL(value, node, "name");
+            GETVAL(ctx, value, node, "name");
             value = transform_schema2json(module, value);
             if (!value) {
                 goto error;
             }
 
             if (unres_schema_add_str(module, unres, ident, UNRES_IDENT, value) == -1) {
-                lydict_remove(module->ctx, value);
+                lydict_remove(ctx, value);
                 goto error;
             }
-            lydict_remove(module->ctx, value);
+            lydict_remove(ctx, value);
         } else if (!strcmp(node->name, "if-feature")) {
             rc = fill_yin_iffeature((struct lys_node *)ident, 0, node, &ident->iffeature[ident->iffeature_size], unres);
             ident->iffeature_size++;
@@ -443,6 +445,7 @@
 {
     struct lyxml_elem *child, *next;
     const char *value;
+    struct ly_ctx *ctx = module->ctx;
 
     LY_TREE_FOR_SAFE(yin->child, next, child) {
         if (!child->ns) {
@@ -455,52 +458,52 @@
             }
         } else if (!strcmp(child->name, "description")) {
             if (restr->dsc) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
                 return EXIT_FAILURE;
             }
             if (lyp_yin_parse_subnode_ext(module, restr, LYEXT_PAR_RESTR, child, LYEXT_SUBSTMT_DESCRIPTION, 0, unres)) {
                 return EXIT_FAILURE;
             }
-            restr->dsc = read_yin_subnode(module->ctx, child, "text");
+            restr->dsc = read_yin_subnode(ctx, child, "text");
             if (!restr->dsc) {
                 return EXIT_FAILURE;
             }
         } else if (!strcmp(child->name, "reference")) {
             if (restr->ref) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
                 return EXIT_FAILURE;
             }
             if (lyp_yin_parse_subnode_ext(module, restr, LYEXT_PAR_RESTR, child, LYEXT_SUBSTMT_REFERENCE, 0, unres)) {
                 return EXIT_FAILURE;
             }
-            restr->ref = read_yin_subnode(module->ctx, child, "text");
+            restr->ref = read_yin_subnode(ctx, child, "text");
             if (!restr->ref) {
                 return EXIT_FAILURE;
             }
         } else if (!strcmp(child->name, "error-app-tag")) {
             if (restr->eapptag) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
                 return EXIT_FAILURE;
             }
             if (lyp_yin_parse_subnode_ext(module, restr, LYEXT_PAR_RESTR, child, LYEXT_SUBSTMT_ERRTAG, 0, unres)) {
                 return EXIT_FAILURE;
             }
-            GETVAL(value, child, "value");
-            restr->eapptag = lydict_insert(module->ctx, value, 0);
+            GETVAL(ctx, value, child, "value");
+            restr->eapptag = lydict_insert(ctx, value, 0);
         } else if (!strcmp(child->name, "error-message")) {
             if (restr->emsg) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
                 return EXIT_FAILURE;
             }
             if (lyp_yin_parse_subnode_ext(module, restr, LYEXT_PAR_RESTR, child, LYEXT_SUBSTMT_ERRMSG, 0, unres)) {
                 return EXIT_FAILURE;
             }
-            restr->emsg = read_yin_subnode(module->ctx, child, "value");
+            restr->emsg = read_yin_subnode(ctx, child, "value");
             if (!restr->emsg) {
                 return EXIT_FAILURE;
             }
         } else {
-            LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
             return EXIT_FAILURE;
         }
     }
@@ -523,6 +526,7 @@
     struct lys_type_bit bit, *bits_sc = NULL;
     struct lys_type_enum *enms_sc = NULL; /* shortcut */
     struct lys_type *dertype;
+    struct ly_ctx *ctx = module->ctx;
     int rc, val_set, c_ftrs, c_ext = 0;
     unsigned int i, j;
     int ret = -1;
@@ -535,7 +539,7 @@
     /* init */
     memset(&exts, 0, sizeof exts);
 
-    GETVAL(value, yin, "name");
+    GETVAL(ctx, value, yin, "name");
     value = transform_schema2json(module, value);
     if (!value) {
         goto error;
@@ -543,19 +547,19 @@
 
     i = parse_identifier(value);
     if (i < 1) {
-        LOGVAL(LYE_INCHAR, LY_VLOG_NONE, NULL, value[-i], &value[-i]);
-        lydict_remove(module->ctx, value);
+        LOGVAL(ctx, LYE_INCHAR, LY_VLOG_NONE, NULL, value[-i], &value[-i]);
+        lydict_remove(ctx, value);
         goto error;
     }
     /* module name */
     name = value;
     if (value[i]) {
-        module_name = lydict_insert(module->ctx, value, i);
+        module_name = lydict_insert(ctx, value, i);
         name += i;
         if ((name[0] != ':') || (parse_identifier(name + 1) < 1)) {
-            LOGVAL(LYE_INCHAR, LY_VLOG_NONE, NULL, name[0], name);
-            lydict_remove(module->ctx, module_name);
-            lydict_remove(module->ctx, value);
+            LOGVAL(ctx, LYE_INCHAR, LY_VLOG_NONE, NULL, name[0], name);
+            lydict_remove(ctx, module_name);
+            lydict_remove(ctx, value);
             goto error;
         }
         /* name is in dictionary, but moved */
@@ -564,21 +568,21 @@
 
     rc = resolve_superior_type(name, module_name, module, parent, &type->der);
     if (rc == -1) {
-        LOGVAL(LYE_INMOD, LY_VLOG_NONE, NULL, module_name);
-        lydict_remove(module->ctx, module_name);
-        lydict_remove(module->ctx, value);
+        LOGVAL(ctx, LYE_INMOD, LY_VLOG_NONE, NULL, module_name);
+        lydict_remove(ctx, module_name);
+        lydict_remove(ctx, value);
         goto error;
 
     /* the type could not be resolved or it was resolved to an unresolved typedef */
     } else if (rc == EXIT_FAILURE) {
-        LOGVAL(LYE_NORESOLV, LY_VLOG_NONE, NULL, "type", name);
-        lydict_remove(module->ctx, module_name);
-        lydict_remove(module->ctx, value);
+        LOGVAL(ctx, LYE_NORESOLV, LY_VLOG_NONE, NULL, "type", name);
+        lydict_remove(ctx, module_name);
+        lydict_remove(ctx, value);
         ret = EXIT_FAILURE;
         goto error;
     }
-    lydict_remove(module->ctx, module_name);
-    lydict_remove(module->ctx, value);
+    lydict_remove(ctx, module_name);
+    lydict_remove(ctx, value);
 
     if (type->base == LY_TYPE_ERR) {
         /* resolved type in grouping, decrease the grouping's nacm number to indicate that one less
@@ -588,7 +592,7 @@
             assert(((struct lys_node_grp *)siter)->unres_count);
             ((struct lys_node_grp *)siter)->unres_count--;
         } else {
-            LOGINT;
+            LOGINT(ctx);
             goto error;
         }
     }
@@ -596,7 +600,7 @@
 
     /* check status */
     if (lyp_check_status(type->parent->flags, type->parent->module, type->parent->name,
-                     type->der->flags, type->der->module, type->der->name,  parent)) {
+                         type->der->flags, type->der->module, type->der->name,  parent)) {
         return -1;
     }
 
@@ -604,22 +608,22 @@
     LY_TREE_FOR_SAFE(yin->child, next, node) {
         if (!node->ns) {
             /* garbage */
-            lyxml_free(module->ctx, node);
+            lyxml_free(ctx, node);
             continue;
         } else if (!strcmp(node->ns->value, LY_NSYIN)) {
             /* YANG (YIN) statements - process later */
             continue;
         }
 
-        YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ext, type->ext_size, "extensions", "type", error);
+        YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ext, type->ext_size, "extensions", "type", error);
 
-        lyxml_unlink_elem(module->ctx, node, 2);
-        lyxml_add_child(module->ctx, &exts, node);
+        lyxml_unlink_elem(ctx, node, 2);
+        lyxml_add_child(ctx, &exts, node);
         c_ext++;
     }
     if (c_ext) {
         type->ext = calloc(c_ext, sizeof *type->ext);
-        LY_CHECK_ERR_GOTO(!type->ext, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!type->ext, LOGMEM(ctx), error);
 
         LY_TREE_FOR_SAFE(exts.child, next, node) {
             rc = lyp_yin_fill_ext(type, LYEXT_PAR_TYPE, 0, 0, module, node, &type->ext, type->ext_size, unres);
@@ -637,11 +641,11 @@
         /* get bit specifications, at least one must be present */
         LY_TREE_FOR_SAFE(yin->child, next, node) {
             if (!strcmp(node->name, "bit")) {
-                YIN_CHECK_ARRAY_OVERFLOW_CODE(type->info.bits.count, type->info.bits.count, "bits", "type",
+                YIN_CHECK_ARRAY_OVERFLOW_CODE(ctx, type->info.bits.count, type->info.bits.count, "bits", "type",
                                               type->info.bits.count = 0; goto error);
                 type->info.bits.count++;
             } else {
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, node->name);
+                LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->name);
                 type->info.bits.count = 0;
                 goto error;
             }
@@ -650,7 +654,7 @@
         if (!dertype->der) {
             if (!type->info.bits.count) {
                 /* type is derived directly from buit-in bits type and bit statement is required */
-                LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "bit", "type");
+                LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "bit", "type");
                 goto error;
             }
         } else {
@@ -658,14 +662,14 @@
             if (module->version < 2 && type->info.bits.count) {
                 /* type is not directly derived from buit-in bits type and bit statement is prohibited,
                  * since YANG 1.1 the bit statements can be used to restrict the base bits type */
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, "bit");
+                LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, "bit");
                 type->info.bits.count = 0;
                 goto error;
             }
         }
 
         type->info.bits.bit = calloc(type->info.bits.count, sizeof *type->info.bits.bit);
-        LY_CHECK_ERR_GOTO(!type->info.bits.bit, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!type->info.bits.bit, LOGMEM(ctx), error);
 
         p = 0;
         i = -1;
@@ -673,12 +677,12 @@
             i++;
             c_ftrs = 0;
 
-            GETVAL(value, next, "name");
-            if (lyp_check_identifier(value, LY_IDENT_SIMPLE, NULL, NULL)) {
+            GETVAL(ctx, value, next, "name");
+            if (lyp_check_identifier(ctx, value, LY_IDENT_SIMPLE, NULL, NULL)) {
                 goto error;
             }
 
-            type->info.bits.bit[i].name = lydict_insert(module->ctx, value, strlen(value));
+            type->info.bits.bit[i].name = lydict_insert(ctx, value, strlen(value));
             if (read_yin_common(module, NULL, &type->info.bits.bit[i], LYEXT_PAR_TYPE_BIT, next, 0, unres)) {
                 type->info.bits.count = i + 1;
                 goto error;
@@ -688,7 +692,7 @@
                 /* check the name uniqueness */
                 for (j = 0; j < i; j++) {
                     if (!strcmp(type->info.bits.bit[j].name, type->info.bits.bit[i].name)) {
-                        LOGVAL(LYE_BITS_DUPNAME, LY_VLOG_NONE, NULL, type->info.bits.bit[i].name);
+                        LOGVAL(ctx, LYE_BITS_DUPNAME, LY_VLOG_NONE, NULL, type->info.bits.bit[i].name);
                         type->info.bits.count = i + 1;
                         goto error;
                     }
@@ -702,7 +706,7 @@
                     }
                 }
                 if (j == dertype->info.bits.count) {
-                    LOGVAL(LYE_BITS_INNAME, LY_VLOG_NONE, NULL, value);
+                    LOGVAL(ctx, LYE_BITS_INNAME, LY_VLOG_NONE, NULL, value);
                     type->info.bits.count = i + 1;
                     goto error;
                 }
@@ -717,22 +721,22 @@
                 } else if (strcmp(node->ns->value, LY_NSYIN)) {
                     /* extension */
                     if (lyp_yin_parse_subnode_ext(module, &type->info.bits.bit[i], LYEXT_PAR_TYPE_BIT, node,
-                                             LYEXT_SUBSTMT_SELF, 0, unres)) {
+                                                  LYEXT_SUBSTMT_SELF, 0, unres)) {
                         goto error;
                     }
                 } else if (!strcmp(node->name, "position")) {
                     if (p_ != -1) {
-                        LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, next->name);
+                        LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, next->name);
                         type->info.bits.count = i + 1;
                         goto error;
                     }
 
-                    GETVAL(value, node, "value");
+                    GETVAL(ctx, value, node, "value");
                     p_ = strtoll(value, NULL, 10);
 
                     /* range check */
                     if (p_ < 0 || p_ > UINT32_MAX) {
-                        LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, "bit/position");
+                        LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, "bit/position");
                         type->info.bits.count = i + 1;
                         goto error;
                     }
@@ -747,7 +751,7 @@
                             /* check that the value is unique */
                             for (j = 0; j < i; j++) {
                                 if (type->info.bits.bit[j].pos == type->info.bits.bit[i].pos) {
-                                    LOGVAL(LYE_BITS_DUPVAL, LY_VLOG_NONE, NULL,
+                                    LOGVAL(ctx, LYE_BITS_DUPVAL, LY_VLOG_NONE, NULL,
                                            type->info.bits.bit[i].pos, type->info.bits.bit[i].name,
                                            type->info.bits.bit[j].name);
                                     type->info.bits.count = i + 1;
@@ -762,10 +766,10 @@
                         goto error;
                     }
                 } else if ((module->version >= 2) && !strcmp(node->name, "if-feature")) {
-                    YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ftrs, type->info.bits.bit[i].iffeature_size, "if-features", "bit", error);
+                    YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ftrs, type->info.bits.bit[i].iffeature_size, "if-features", "bit", error);
                     c_ftrs++;
                 } else {
-                    LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, node->name);
+                    LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->name);
                     goto error;
                 }
             }
@@ -774,7 +778,7 @@
                 if (p_ == -1) {
                     /* assign value automatically */
                     if (p > UINT32_MAX) {
-                        LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, "4294967295", "bit/position");
+                        LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, "4294967295", "bit/position");
                         type->info.bits.count = i + 1;
                         goto error;
                     }
@@ -793,7 +797,7 @@
                     if (p_ != bits_sc[j].pos) {
                         /* p_ - assigned position in restricted bits
                          * bits_sc[j].pos - position assigned to the corresponding bit (detected above) in base type */
-                        LOGVAL(LYE_BITS_INVAL, LY_VLOG_NONE, NULL, type->info.bits.bit[i].pos,
+                        LOGVAL(ctx, LYE_BITS_INVAL, LY_VLOG_NONE, NULL, type->info.bits.bit[i].pos,
                                type->info.bits.bit[i].name, bits_sc[j].pos);
                         type->info.bits.count = i + 1;
                         goto error;
@@ -806,7 +810,7 @@
                 bits_sc = &type->info.bits.bit[i];
                 bits_sc->iffeature = calloc(c_ftrs, sizeof *bits_sc->iffeature);
                 if (!bits_sc->iffeature) {
-                    LOGMEM;
+                    LOGMEM(ctx);
                     type->info.bits.count = i + 1;
                     goto error;
                 }
@@ -842,14 +846,14 @@
 
             if (!strcmp(node->name, "range")) {
                 if (type->info.dec64.range) {
-                    LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name);
+                    LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name);
                     goto error;
                 }
 
-                GETVAL(value, node, "value");
+                GETVAL(ctx, value, node, "value");
                 type->info.dec64.range = calloc(1, sizeof *type->info.dec64.range);
-                LY_CHECK_ERR_GOTO(!type->info.dec64.range, LOGMEM, error);
-                type->info.dec64.range->expr = lydict_insert(module->ctx, value, 0);
+                LY_CHECK_ERR_GOTO(!type->info.dec64.range, LOGMEM(ctx), error);
+                type->info.dec64.range->expr = lydict_insert(ctx, value, 0);
 
                 /* get possible substatements */
                 if (read_restr_substmt(module, type->info.dec64.range, node, unres)) {
@@ -857,15 +861,15 @@
                 }
             } else if (!strcmp(node->name, "fraction-digits")) {
                 if (type->info.dec64.dig) {
-                    LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name);
+                    LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name);
                     goto error;
                 }
-                GETVAL(value, node, "value");
+                GETVAL(ctx, value, node, "value");
                 v = strtol(value, NULL, 10);
 
                 /* range check */
                 if (v < 1 || v > 18) {
-                    LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, node->name);
+                    LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, node->name);
                     goto error;
                 }
                 type->info.dec64.dig = (uint8_t)v;
@@ -879,7 +883,7 @@
                     goto error;
                 }
             } else {
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, node->name);
+                LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->name);
                 goto error;
             }
         }
@@ -887,12 +891,12 @@
         /* mandatory sub-statement(s) check */
         if (!type->info.dec64.dig && !type->der->type.der) {
             /* decimal64 type directly derived from built-in type requires fraction-digits */
-            LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "fraction-digits", "type");
+            LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "fraction-digits", "type");
             goto error;
         }
         if (type->info.dec64.dig && type->der->type.der) {
             /* type is not directly derived from buit-in type and fraction-digits statement is prohibited */
-            LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, "fraction-digits");
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, "fraction-digits");
             goto error;
         }
 
@@ -902,8 +906,8 @@
             type->info.dec64.div = type->der->type.info.dec64.div;
         }
 
-        if (type->info.dec64.range && lyp_check_length_range(type->info.dec64.range->expr, type)) {
-            LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, "range");
+        if (type->info.dec64.range && lyp_check_length_range(ctx, type->info.dec64.range->expr, type)) {
+            LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, "range");
             goto error;
         }
         break;
@@ -915,11 +919,11 @@
         LY_TREE_FOR_SAFE(yin->child, next, node) {
 
             if (!strcmp(node->name, "enum")) {
-                YIN_CHECK_ARRAY_OVERFLOW_CODE(type->info.enums.count, type->info.enums.count, "enums", "type",
+                YIN_CHECK_ARRAY_OVERFLOW_CODE(ctx, type->info.enums.count, type->info.enums.count, "enums", "type",
                                               type->info.enums.count = 0; goto error);
                 type->info.enums.count++;
             } else {
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, node->name);
+                LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->name);
                 type->info.enums.count = 0;
                 goto error;
             }
@@ -928,7 +932,7 @@
         if (!dertype->der) {
             if (!type->info.enums.count) {
                 /* type is derived directly from buit-in enumeartion type and enum statement is required */
-                LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "enum", "type");
+                LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "enum", "type");
                 goto error;
             }
         } else {
@@ -936,14 +940,14 @@
             if (module->version < 2 && type->info.enums.count) {
                 /* type is not directly derived from built-in enumeration type and enum statement is prohibited
                  * in YANG 1.0, since YANG 1.1 enum statements can be used to restrict the base enumeration type */
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, "enum");
+                LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, "enum");
                 type->info.enums.count = 0;
                 goto error;
             }
         }
 
         type->info.enums.enm = calloc(type->info.enums.count, sizeof *type->info.enums.enm);
-        LY_CHECK_ERR_GOTO(!type->info.enums.enm, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!type->info.enums.enm, LOGMEM(ctx), error);
 
         v = 0;
         i = -1;
@@ -951,13 +955,13 @@
             i++;
             c_ftrs = 0;
 
-            GETVAL(value, next, "name");
+            GETVAL(ctx, value, next, "name");
             if (!value[0]) {
-                LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, "enum name");
-                LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Enum name must not be empty.");
+                LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, "enum name");
+                LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Enum name must not be empty.");
                 goto error;
             }
-            type->info.enums.enm[i].name = lydict_insert(module->ctx, value, strlen(value));
+            type->info.enums.enm[i].name = lydict_insert(ctx, value, strlen(value));
             if (read_yin_common(module, NULL, &type->info.enums.enm[i], LYEXT_PAR_TYPE_ENUM, next, 0, unres)) {
                 type->info.enums.count = i + 1;
                 goto error;
@@ -966,7 +970,7 @@
             /* the assigned name MUST NOT have any leading or trailing whitespace characters */
             value = type->info.enums.enm[i].name;
             if (isspace(value[0]) || isspace(value[strlen(value) - 1])) {
-                LOGVAL(LYE_ENUM_WS, LY_VLOG_NONE, NULL, value);
+                LOGVAL(ctx, LYE_ENUM_WS, LY_VLOG_NONE, NULL, value);
                 type->info.enums.count = i + 1;
                 goto error;
             }
@@ -975,7 +979,7 @@
                 /* check the name uniqueness */
                 for (j = 0; j < i; j++) {
                     if (ly_strequal(type->info.enums.enm[j].name, value, 1)) {
-                        LOGVAL(LYE_ENUM_DUPNAME, LY_VLOG_NONE, NULL, value);
+                        LOGVAL(ctx, LYE_ENUM_DUPNAME, LY_VLOG_NONE, NULL, value);
                         type->info.enums.count = i + 1;
                         goto error;
                     }
@@ -989,7 +993,7 @@
                     }
                 }
                 if (j == dertype->info.enums.count) {
-                    LOGVAL(LYE_ENUM_INNAME, LY_VLOG_NONE, NULL, value);
+                    LOGVAL(ctx, LYE_ENUM_INNAME, LY_VLOG_NONE, NULL, value);
                     type->info.enums.count = i + 1;
                     goto error;
                 }
@@ -1008,17 +1012,17 @@
                     }
                 } else if (!strcmp(node->name, "value")) {
                     if (val_set) {
-                        LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, next->name);
+                        LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, next->name);
                         type->info.enums.count = i + 1;
                         goto error;
                     }
 
-                    GETVAL(value, node, "value");
+                    GETVAL(ctx, value, node, "value");
                     v_ = strtoll(value, NULL, 10);
 
                     /* range check */
                     if (v_ < INT32_MIN || v_ > INT32_MAX) {
-                        LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, "enum/value");
+                        LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, "enum/value");
                         type->info.enums.count = i + 1;
                         goto error;
                     }
@@ -1038,7 +1042,7 @@
                                 /* check that the value is unique */
                                 for (j = 0; j < i; j++) {
                                     if (type->info.enums.enm[j].value == type->info.enums.enm[i].value) {
-                                        LOGVAL(LYE_ENUM_DUPVAL, LY_VLOG_NONE, NULL,
+                                        LOGVAL(ctx, LYE_ENUM_DUPVAL, LY_VLOG_NONE, NULL,
                                                type->info.enums.enm[i].value, type->info.enums.enm[i].name,
                                                type->info.enums.enm[j].name);
                                         type->info.enums.count = i + 1;
@@ -1055,11 +1059,11 @@
                         goto error;
                     }
                 } else if ((module->version >= 2) && !strcmp(node->name, "if-feature")) {
-                    YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ftrs, type->info.enums.enm[i].iffeature_size, "if-features", "enum", error);
+                    YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ftrs, type->info.enums.enm[i].iffeature_size, "if-features", "enum", error);
                     c_ftrs++;
 
                 } else {
-                    LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, node->name);
+                    LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->name);
                     goto error;
                 }
             }
@@ -1068,7 +1072,7 @@
                 if (!val_set) {
                     /* assign value automatically */
                     if (v > INT32_MAX) {
-                        LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, "2147483648", "enum/value");
+                        LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, "2147483648", "enum/value");
                         type->info.enums.count = i + 1;
                         goto error;
                     }
@@ -1087,7 +1091,7 @@
                     if (v_ != enms_sc[j].value) {
                         /* v_ - assigned value in restricted enum
                          * enms_sc[j].value - value assigned to the corresponding enum (detected above) in base type */
-                        LOGVAL(LYE_ENUM_INVAL, LY_VLOG_NONE, NULL,
+                        LOGVAL(ctx, LYE_ENUM_INVAL, LY_VLOG_NONE, NULL,
                                type->info.enums.enm[i].value, type->info.enums.enm[i].name, enms_sc[j].value);
                         type->info.enums.count = i + 1;
                         goto error;
@@ -1100,7 +1104,7 @@
                 enms_sc = &type->info.enums.enm[i];
                 enms_sc->iffeature = calloc(c_ftrs, sizeof *enms_sc->iffeature);
                 if (!enms_sc->iffeature) {
-                    LOGMEM;
+                    LOGMEM(ctx);
                     type->info.enums.count = i + 1;
                     goto error;
                 }
@@ -1128,18 +1132,18 @@
         LY_TREE_FOR_SAFE(yin->child, next, node) {
 
             if (strcmp(node->name, "base")) {
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, node->name);
+                LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->name);
                 goto error;
             }
 
-            GETVAL(value, yin->child, "name");
+            GETVAL(ctx, value, yin->child, "name");
             /* store in the JSON format */
             value = transform_schema2json(module, value);
             if (!value) {
                 goto error;
             }
             rc = unres_schema_add_str(module, unres, type, UNRES_TYPE_IDENTREF, value);
-            lydict_remove(module->ctx, value);
+            lydict_remove(ctx, value);
             if (rc == -1) {
                 goto error;
             }
@@ -1154,16 +1158,16 @@
                 /* this is just a derived type with no base required */
                 break;
             }
-            LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "base", "type");
+            LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "base", "type");
             goto error;
         } else {
             if (type->der->type.der) {
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, "base");
+                LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, "base");
                 goto error;
             }
         }
         if (yin->child->next) {
-            LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, yin->child->next->name, yin->name);
+            LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, yin->child->next->name, yin->name);
             goto error;
         }
         break;
@@ -1174,16 +1178,16 @@
 
             if (!strcmp(node->name, "require-instance")) {
                 if (type->info.inst.req) {
-                    LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name);
+                    LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name);
                     goto error;
                 }
-                GETVAL(value, node, "value");
+                GETVAL(ctx, value, node, "value");
                 if (!strcmp(value, "true")) {
                     type->info.inst.req = 1;
                 } else if (!strcmp(value, "false")) {
                     type->info.inst.req = -1;
                 } else {
-                    LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, node->name);
+                    LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, node->name);
                     goto error;
                 }
 
@@ -1192,7 +1196,7 @@
                     goto error;
                 }
             } else {
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, node->name);
+                LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->name);
                 goto error;
             }
         }
@@ -1227,25 +1231,25 @@
 
             if (!strcmp(node->name, name)) {
                 if (*restrs) {
-                    LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name);
+                    LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name);
                     goto error;
                 }
 
-                GETVAL(value, node, "value");
-                if (lyp_check_length_range(value, type)) {
-                    LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, name);
+                GETVAL(ctx, value, node, "value");
+                if (lyp_check_length_range(ctx, value, type)) {
+                    LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, name);
                     goto error;
                 }
                 *restrs = calloc(1, sizeof **restrs);
-                LY_CHECK_ERR_GOTO(!(*restrs), LOGMEM, error);
-                (*restrs)->expr = lydict_insert(module->ctx, value, 0);
+                LY_CHECK_ERR_GOTO(!(*restrs), LOGMEM(ctx), error);
+                (*restrs)->expr = lydict_insert(ctx, value, 0);
 
                 /* get possible substatements */
                 if (read_restr_substmt(module, *restrs, node, unres)) {
                     goto error;
                 }
             } else {
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, node->name);
+                LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->name);
                 goto error;
             }
         }
@@ -1266,11 +1270,11 @@
 
             if (!strcmp(node->name, "path") && !type->der->type.der) {
                 if (type->info.lref.path) {
-                    LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name);
+                    LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name);
                     goto error;
                 }
 
-                GETVAL(value, node, "value");
+                GETVAL(ctx, value, node, "value");
                 /* store in the JSON format */
                 type->info.lref.path = transform_schema2json(module, value);
                 if (!type->info.lref.path) {
@@ -1294,16 +1298,16 @@
                 }
             } else if (module->version >= 2 && !strcmp(node->name, "require-instance")) {
                 if (type->info.lref.req) {
-                    LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name);
+                    LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name);
                     goto error;
                 }
-                GETVAL(value, node, "value");
+                GETVAL(ctx, value, node, "value");
                 if (!strcmp(value, "true")) {
                     type->info.lref.req = 1;
                 } else if (!strcmp(value, "false")) {
                     type->info.lref.req = -1;
                 } else {
-                    LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, node->name);
+                    LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, node->name);
                     goto error;
                 }
 
@@ -1312,18 +1316,18 @@
                     goto error;
                 }
             } else {
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, node->name);
+                LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->name);
                 goto error;
             }
         }
 
         if (!type->info.lref.path) {
             if (!type->der->type.der) {
-                LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "path", "type");
+                LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "path", "type");
                 goto error;
             } else {
                 /* copy leafref definition into the derived type */
-                type->info.lref.path = lydict_insert(module->ctx, type->der->type.info.lref.path, 0);
+                type->info.lref.path = lydict_insert(ctx, type->der->type.info.lref.path, 0);
                 /* and resolve the path at the place we are (if not in grouping/typedef) */
                 if (!parenttype && unres_schema_add_node(module, unres, type, UNRES_TYPE_LEAFREF, parent) == -1) {
                     goto error;
@@ -1341,29 +1345,29 @@
 
             if (!strcmp(node->name, "length")) {
                 if (type->info.str.length) {
-                    LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name);
+                    LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name);
                     goto error;
                 }
 
-                GETVAL(value, node, "value");
-                if (lyp_check_length_range(value, type)) {
-                    LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, "length");
+                GETVAL(ctx, value, node, "value");
+                if (lyp_check_length_range(ctx, value, type)) {
+                    LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, "length");
                     goto error;
                 }
                 type->info.str.length = calloc(1, sizeof *type->info.str.length);
-                LY_CHECK_ERR_GOTO(!type->info.str.length, LOGMEM, error);
-                type->info.str.length->expr = lydict_insert(module->ctx, value, 0);
+                LY_CHECK_ERR_GOTO(!type->info.str.length, LOGMEM(ctx), error);
+                type->info.str.length->expr = lydict_insert(ctx, value, 0);
 
                 /* get possible sub-statements */
                 if (read_restr_substmt(module, type->info.str.length, node, unres)) {
                     goto error;
                 }
-                lyxml_free(module->ctx, node);
+                lyxml_free(ctx, node);
             } else if (!strcmp(node->name, "pattern")) {
-                YIN_CHECK_ARRAY_OVERFLOW_GOTO(i, type->info.str.pat_count, "patterns", "type", error);
+                YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, i, type->info.str.pat_count, "patterns", "type", error);
                 i++;
             } else {
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, node->name);
+                LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->name);
                 goto error;
             }
         }
@@ -1373,21 +1377,21 @@
                 in_grp = 1;
             }
             type->info.str.patterns = calloc(i, sizeof *type->info.str.patterns);
-            LY_CHECK_ERR_GOTO(!type->info.str.patterns, LOGMEM, error);
+            LY_CHECK_ERR_GOTO(!type->info.str.patterns, LOGMEM(ctx), error);
 #ifdef LY_ENABLED_CACHE
             if (!in_grp) {
                 /* do not compile patterns in groupings */
                 type->info.str.patterns_pcre = calloc(2 * i, sizeof *type->info.str.patterns_pcre);
-                LY_CHECK_ERR_GOTO(!type->info.str.patterns_pcre, LOGMEM, error);
+                LY_CHECK_ERR_GOTO(!type->info.str.patterns_pcre, LOGMEM(ctx), error);
             }
 #endif
             LY_TREE_FOR(yin->child, node) {
-                GETVAL(value, node, "value");
+                GETVAL(ctx, value, node, "value");
 
-                if (!(module->ctx->models.flags & LY_CTX_TRUSTED)) {
+                if (!(ctx->models.flags & LY_CTX_TRUSTED)) {
                     if (in_grp) {
                         /* in grouping, just check the pattern syntax */
-                        if (lyp_check_pattern(value, NULL)) {
+                        if (lyp_check_pattern(ctx, value, NULL)) {
                             goto error;
                         }
                     }
@@ -1411,15 +1415,15 @@
                     LY_TREE_FOR_SAFE(node->child, next2, child) {
                         if (child->ns && !strcmp(child->ns->value, LY_NSYIN) && !strcmp(child->name, "modifier")) {
                             if (name) {
-                                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "modifier", node->name);
+                                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, "modifier", node->name);
                                 goto error;
                             }
 
-                            GETVAL(name, child, "value");
+                            GETVAL(ctx, name, child, "value");
                             if (!strcmp(name, "invert-match")) {
                                 modifier = 0x15; /* NACK */
                             } else {
-                                LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, name, "modifier");
+                                LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, name, "modifier");
                                 goto error;
                             }
                             /* get extensions of the modifier */
@@ -1428,18 +1432,18 @@
                                 goto error;
                             }
 
-                            lyxml_free(module->ctx, child);
+                            lyxml_free(ctx, child);
                         }
                     }
                 }
 
                 len = strlen(value);
                 buf = malloc((len + 2) * sizeof *buf); /* modifier byte + value + terminating NULL byte */
-                LY_CHECK_ERR_GOTO(!buf, LOGMEM, error);
+                LY_CHECK_ERR_GOTO(!buf, LOGMEM(ctx), error);
                 buf[0] = modifier;
                 strcpy(&buf[1], value);
 
-                restr->expr = lydict_insert_zc(module->ctx, buf);
+                restr->expr = lydict_insert_zc(ctx, buf);
 
                 /* get possible sub-statements */
                 if (read_restr_substmt(module, restr, node, unres)) {
@@ -1458,19 +1462,19 @@
             if (!strcmp(node->name, "type")) {
                 if (type->der->type.der) {
                     /* type can be a substatement only in "union" type, not in derived types */
-                    LOGVAL(LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, "type", "derived type");
+                    LOGVAL(ctx, LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, "type", "derived type");
                     goto error;
                 }
-                YIN_CHECK_ARRAY_OVERFLOW_GOTO(i, type->info.uni.count, "types", "type", error);
+                YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, i, type->info.uni.count, "types", "type", error);
                 i++;
             } else {
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, node->name);
+                LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->name);
                 goto error;
             }
         }
 
         if (!i && !type->der->type.der) {
-            LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "type", "(union) type");
+            LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "type", "(union) type");
             goto error;
         }
 
@@ -1482,7 +1486,7 @@
         /* allocate array for union's types ... */
         if (i) {
             type->info.uni.types = calloc(i, sizeof *type->info.uni.types);
-            LY_CHECK_ERR_GOTO(!type->info.uni.types, LOGMEM, error);
+            LY_CHECK_ERR_GOTO(!type->info.uni.types, LOGMEM(ctx), error);
         }
 
         /* ... and fill the structures */
@@ -1495,10 +1499,10 @@
                 if (module->version < 2) {
                     /* union's type cannot be empty or leafref */
                     if (type->info.uni.types[type->info.uni.count - 1].base == LY_TYPE_EMPTY) {
-                        LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, "empty", node->name);
+                        LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, "empty", node->name);
                         rc = -1;
                     } else if (type->info.uni.types[type->info.uni.count - 1].base == LY_TYPE_LEAFREF) {
-                        LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, "leafref", node->name);
+                        LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, "leafref", node->name);
                         rc = -1;
                     }
                 }
@@ -1511,7 +1515,7 @@
             if (rc) {
                 /* even if we got EXIT_FAILURE, throw it all away, too much trouble doing something else */
                 for (i = 0; i < type->info.uni.count; ++i) {
-                    lys_type_free(module->ctx, &type->info.uni.types[i], NULL);
+                    lys_type_free(ctx, &type->info.uni.types[i], NULL);
                 }
                 free(type->info.uni.types);
                 type->info.uni.types = NULL;
@@ -1532,21 +1536,20 @@
     case LY_TYPE_EMPTY:
         /* no sub-statement allowed */
         if (yin->child) {
-            LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, yin->child->name);
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, yin->child->name);
             goto error;
         }
         break;
 
     default:
-        LOGINT;
+        LOGINT(ctx);
         goto error;
     }
 
     return EXIT_SUCCESS;
 
 error:
-    lyxml_free_withsiblings(module->ctx, exts.child);
-
+    lyxml_free_withsiblings(ctx, exts.child);
     return ret;
 }
 
@@ -1557,14 +1560,15 @@
 {
     const char *value;
     struct lyxml_elem *node, *next;
+    struct ly_ctx *ctx = module->ctx;
     int rc, has_type = 0, c_ext = 0;
     void *reallocated;
 
-    GETVAL(value, yin, "name");
-    if (lyp_check_identifier(value, LY_IDENT_TYPE, module, parent)) {
+    GETVAL(ctx, value, yin, "name");
+    if (lyp_check_identifier(ctx, value, LY_IDENT_TYPE, module, parent)) {
         goto error;
     }
-    tpdf->name = lydict_insert(module->ctx, value, strlen(value));
+    tpdf->name = lydict_insert(ctx, value, strlen(value));
 
     /* generic part - status, description, reference */
     if (read_yin_common(module, NULL, tpdf, LYEXT_PAR_TPDF, yin, OPT_MODULE, unres)) {
@@ -1574,12 +1578,12 @@
     LY_TREE_FOR_SAFE(yin->child, next, node) {
         if (strcmp(node->ns->value, LY_NSYIN)) {
             /* extension */
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ext, tpdf->ext_size, "extensions", "typedef", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ext, tpdf->ext_size, "extensions", "typedef", error);
             c_ext++;
             continue;
         } else if (!strcmp(node->name, "type")) {
             if (has_type) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name);
                 goto error;
             }
             /* HACK for unres */
@@ -1594,43 +1598,43 @@
             continue;
         } else if (!strcmp(node->name, "default")) {
             if (tpdf->dflt) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name);
                 goto error;
             }
-            GETVAL(value, node, "value");
-            tpdf->dflt = lydict_insert(module->ctx, value, strlen(value));
+            GETVAL(ctx, value, node, "value");
+            tpdf->dflt = lydict_insert(ctx, value, strlen(value));
 
             if (lyp_yin_parse_subnode_ext(module, tpdf, LYEXT_PAR_TPDF, node, LYEXT_SUBSTMT_DEFAULT, 0, unres)) {
                 goto error;
             }
         } else if (!strcmp(node->name, "units")) {
             if (tpdf->units) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name);
                 goto error;
             }
-            GETVAL(value, node, "name");
-            tpdf->units = lydict_insert(module->ctx, value, strlen(value));
+            GETVAL(ctx, value, node, "name");
+            tpdf->units = lydict_insert(ctx, value, strlen(value));
 
             if (lyp_yin_parse_subnode_ext(module, tpdf, LYEXT_PAR_TPDF, node, LYEXT_SUBSTMT_UNITS, 0, unres)) {
                 goto error;
             }
         } else {
-            LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, value);
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, value);
             goto error;
         }
 
-        lyxml_free(module->ctx, node);
+        lyxml_free(ctx, node);
     }
 
     /* check mandatory value */
     if (!has_type) {
-        LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "type", yin->name);
+        LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "type", yin->name);
         goto error;
     }
 
     /* check default value (if not defined, there still could be some restrictions
      * that need to be checked against a default value from a derived type) */
-    if (!(module->ctx->models.flags & LY_CTX_TRUSTED) &&
+    if (!(ctx->models.flags & LY_CTX_TRUSTED) &&
             unres_schema_add_node(module, unres, &tpdf->type, UNRES_TYPEDEF_DFLT, (struct lys_node *)(&tpdf->dflt)) == -1) {
         goto error;
     }
@@ -1639,7 +1643,7 @@
     if (c_ext) {
         /* some extensions may be already present from the substatements */
         reallocated = realloc(tpdf->ext, (c_ext + tpdf->ext_size) * sizeof *tpdf->ext);
-        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM(ctx), error);
         tpdf->ext = reallocated;
 
         /* init memory */
@@ -1657,24 +1661,24 @@
     return EXIT_SUCCESS;
 
 error:
-
     return EXIT_FAILURE;
 }
 
 static int
 fill_yin_extension(struct lys_module *module, struct lyxml_elem *yin, struct lys_ext *ext, struct unres_schema *unres)
 {
+    struct ly_ctx *ctx = module->ctx;
     const char *value;
     struct lyxml_elem *child, *node, *next, *next2;
     int c_ext = 0, rc;
     void *reallocated;
 
-    GETVAL(value, yin, "name");
+    GETVAL(ctx, value, yin, "name");
 
-    if (lyp_check_identifier(value, LY_IDENT_EXTENSION, module, NULL)) {
+    if (lyp_check_identifier(ctx, value, LY_IDENT_EXTENSION, module, NULL)) {
         goto error;
     }
-    ext->name = lydict_insert(module->ctx, value, strlen(value));
+    ext->name = lydict_insert(ctx, value, strlen(value));
 
     if (read_yin_common(module, NULL, ext, LYEXT_PAR_EXT, yin, OPT_MODULE, unres)) {
         goto error;
@@ -1683,12 +1687,12 @@
     LY_TREE_FOR_SAFE(yin->child, next, node) {
         if (strcmp(node->ns->value, LY_NSYIN)) {
             /* possible extension instance */
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ext, ext->ext_size, "extensions", "extension", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ext, ext->ext_size, "extensions", "extension", error);
             c_ext++;
         } else if (!strcmp(node->name, "argument")) {
             /* argument */
-            GETVAL(value, node, "name");
-            ext->argument = lydict_insert(module->ctx, value, strlen(value));
+            GETVAL(ctx, value, node, "name");
+            ext->argument = lydict_insert(ctx, value, strlen(value));
             if (lyp_yin_parse_subnode_ext(module, ext, LYEXT_PAR_EXT, node, LYEXT_SUBSTMT_ARGUMENT, 0, unres)) {
                 goto error;
             }
@@ -1696,7 +1700,7 @@
             /* yin-element */
             LY_TREE_FOR_SAFE(node->child, next2, child) {
                 if (child->ns == node->ns && !strcmp(child->name, "yin-element")) {
-                    GETVAL(value, child, "value");
+                    GETVAL(ctx, value, child, "value");
                     if (ly_strequal(value, "true", 0)) {
                         ext->flags |= LYS_YINELEM;
                     }
@@ -1706,15 +1710,15 @@
                     }
                 } else if (child->ns) {
                     /* unexpected YANG statement */
-                    LOGVAL(LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, child->name, child->name);
+                    LOGVAL(ctx, LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, child->name, child->name);
                     goto error;
                 } /* else garbage, but save resource needed for unlinking */
             }
 
-            lyxml_free(module->ctx, node);
+            lyxml_free(ctx, node);
         } else {
             /* unexpected YANG statement */
-            LOGVAL(LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, node->name, node->name);
+            LOGVAL(ctx, LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, node->name, node->name);
             goto error;
         }
     }
@@ -1722,7 +1726,7 @@
     if (c_ext) {
         /* some extensions may be already present from the substatements */
         reallocated = realloc(ext->ext, (c_ext + ext->ext_size) * sizeof *ext->ext);
-        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM(ctx), error);
         ext->ext = reallocated;
 
         /* init memory */
@@ -1751,16 +1755,17 @@
 static int
 fill_yin_feature(struct lys_module *module, struct lyxml_elem *yin, struct lys_feature *f, struct unres_schema *unres)
 {
+    struct ly_ctx *ctx = module->ctx;
     const char *value;
     struct lyxml_elem *child, *next;
     int c_ftrs = 0, c_ext = 0, ret;
     void *reallocated;
 
-    GETVAL(value, yin, "name");
-    if (lyp_check_identifier(value, LY_IDENT_FEATURE, module, NULL)) {
+    GETVAL(ctx, value, yin, "name");
+    if (lyp_check_identifier(ctx, value, LY_IDENT_FEATURE, module, NULL)) {
         goto error;
     }
-    f->name = lydict_insert(module->ctx, value, strlen(value));
+    f->name = lydict_insert(ctx, value, strlen(value));
     f->module = module;
 
     if (read_yin_common(module, NULL, f, LYEXT_PAR_FEATURE, yin, 0, unres)) {
@@ -1770,25 +1775,25 @@
     LY_TREE_FOR(yin->child, child) {
         if (strcmp(child->ns->value, LY_NSYIN)) {
             /* extension */
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ext, f->ext_size, "extensions", "feature", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ext, f->ext_size, "extensions", "feature", error);
             c_ext++;
         } else if (!strcmp(child->name, "if-feature")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ftrs, f->iffeature_size, "if-feature", "feature", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ftrs, f->iffeature_size, "if-feature", "feature", error);
             c_ftrs++;
         } else {
-            LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
             goto error;
         }
     }
 
     if (c_ftrs) {
         f->iffeature = calloc(c_ftrs, sizeof *f->iffeature);
-        LY_CHECK_ERR_GOTO(!f->iffeature, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!f->iffeature, LOGMEM(ctx), error);
     }
     if (c_ext) {
         /* some extensions may be already present from the substatements */
         reallocated = realloc(f->ext, (c_ext + f->ext_size) * sizeof *f->ext);
-        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM(ctx), error);
         f->ext = reallocated;
 
         /* init memory */
@@ -1822,7 +1827,6 @@
     return EXIT_SUCCESS;
 
 error:
-
     return EXIT_FAILURE;
 }
 
@@ -1832,7 +1836,7 @@
 {
     const char *value;
 
-    GETVAL(value, yin, "condition");
+    GETVAL(module->ctx, value, yin, "condition");
     must->expr = transform_schema2json(module, value);
     if (!must->expr) {
         goto error;
@@ -1848,11 +1852,12 @@
 fill_yin_revision(struct lys_module *module, struct lyxml_elem *yin, struct lys_revision *rev,
                   struct unres_schema *unres)
 {
+    struct ly_ctx *ctx = module->ctx;
     struct lyxml_elem *next, *child;
     const char *value;
 
-    GETVAL(value, yin, "date");
-    if (lyp_check_date(value)) {
+    GETVAL(ctx, value, yin, "date");
+    if (lyp_check_date(ctx, value)) {
         goto error;
     }
     memcpy(rev->date, value, LY_REV_SIZE - 1);
@@ -1869,32 +1874,32 @@
             }
         } else if (!strcmp(child->name, "description")) {
             if (rev->dsc) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
                 goto error;
             }
             if (lyp_yin_parse_subnode_ext(module, rev, LYEXT_PAR_REVISION,
                                           child, LYEXT_SUBSTMT_DESCRIPTION, 0, unres)) {
                 goto error;
             }
-            rev->dsc = read_yin_subnode(module->ctx, child, "text");
+            rev->dsc = read_yin_subnode(ctx, child, "text");
             if (!rev->dsc) {
                 goto error;
             }
         } else if (!strcmp(child->name, "reference")) {
             if (rev->ref) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
                 goto error;
             }
             if (lyp_yin_parse_subnode_ext(module, rev, LYEXT_PAR_REVISION,
                                           child, LYEXT_SUBSTMT_REFERENCE, 0, unres)) {
                 goto error;
             }
-            rev->ref = read_yin_subnode(module->ctx, child, "text");
+            rev->ref = read_yin_subnode(ctx, child, "text");
             if (!rev->ref) {
                 goto error;
             }
         } else {
-            LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
             goto error;
         }
     }
@@ -1909,19 +1914,20 @@
 fill_yin_unique(struct lys_module *module, struct lys_node *parent, struct lyxml_elem *yin, struct lys_unique *unique,
                 struct unres_schema *unres)
 {
+    struct ly_ctx *ctx = module->ctx;
     int i, j, ret = EXIT_FAILURE;
     const char *orig;
     char *value, *vaux, *start = NULL, c;
     struct unres_list_uniq *unique_info;
 
     /* get unique value (list of leafs supposed to be unique */
-    GETVAL(orig, yin, "tag");
+    GETVAL(ctx, orig, yin, "tag");
 
     /* count the number of unique leafs in the value */
     start = value = vaux = strdup(orig);
-    LY_CHECK_ERR_GOTO(!vaux, LOGMEM, error);
+    LY_CHECK_ERR_GOTO(!vaux, LOGMEM(ctx), error);
     while ((vaux = strpbrk(vaux, " \t\n"))) {
-        YIN_CHECK_ARRAY_OVERFLOW_CODE(unique->expr_size, unique->expr_size, "referenced items", "unique",
+        YIN_CHECK_ARRAY_OVERFLOW_CODE(ctx, unique->expr_size, unique->expr_size, "referenced items", "unique",
                                       unique->expr_size = 0; goto error);
         unique->expr_size++;
         while (isspace(*vaux)) {
@@ -1930,7 +1936,7 @@
     }
     unique->expr_size++;
     unique->expr = calloc(unique->expr_size, sizeof *unique->expr);
-    LY_CHECK_ERR_GOTO(!unique->expr, LOGMEM, error);
+    LY_CHECK_ERR_GOTO(!unique->expr, LOGMEM(ctx), error);
 
     for (i = 0; i < unique->expr_size; i++) {
         vaux = strpbrk(value, " \t\n");
@@ -1948,8 +1954,8 @@
         /* check that the expression does not repeat */
         for (j = 0; j < i; j++) {
             if (ly_strequal(unique->expr[j], unique->expr[i], 1)) {
-                LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, unique->expr[i], "unique");
-                LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "The identifier is not unique");
+                LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, unique->expr[i], "unique");
+                LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "The identifier is not unique");
                 goto error;
             }
         }
@@ -1957,7 +1963,7 @@
         /* try to resolve leaf */
         if (unres) {
             unique_info = malloc(sizeof *unique_info);
-            LY_CHECK_ERR_GOTO(!unique_info, LOGMEM, error);
+            LY_CHECK_ERR_GOTO(!unique_info, LOGMEM(ctx), error);
             unique_info->list = parent;
             unique_info->expr = unique->expr[i];
             unique_info->trg_type = &unique->trg_type;
@@ -1972,7 +1978,7 @@
 
         /* move to next token */
         value = vaux;
-        while(value && isspace(*value)) {
+        while (value && isspace(*value)) {
             value++;
         }
     }
@@ -1995,10 +2001,11 @@
     char *endptr;
     unsigned long val;
     uint32_t *ui32val, *min, *max;
+    struct ly_ctx *ctx = target->module->ctx;
 
     /* del min/max is forbidden */
     if (d->mod == LY_DEVIATE_DEL) {
-        LOGVAL(LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, (type ? "max-elements" : "min-elements"), "deviate delete");
+        LOGVAL(ctx, LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, (type ? "max-elements" : "min-elements"), "deviate delete");
         goto error;
     }
 
@@ -2010,12 +2017,12 @@
         max = &((struct lys_node_list *)target)->max;
         min = &((struct lys_node_list *)target)->min;
     } else {
-        LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, node->name);
-        LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Target node does not allow \"%s\" property.", node->name);
+        LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->name);
+        LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Target node does not allow \"%s\" property.", node->name);
         goto error;
     }
 
-    GETVAL(value, node, "value");
+    GETVAL(ctx, value, node, "value");
     while (isspace(value[0])) {
         value++;
     }
@@ -2030,7 +2037,7 @@
         endptr = NULL;
         val = strtoul(value, &endptr, 10);
         if (*endptr || value[0] == '-' || errno || val > UINT32_MAX) {
-            LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, node->name);
+            LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, node->name);
             goto error;
         }
         if (type) {
@@ -2047,8 +2054,8 @@
     if (d->mod == LY_DEVIATE_ADD) {
         /* check that there is no current value */
         if (*ui32val) {
-            LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, node->name);
-            LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Adding property that already exists.");
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->name);
+            LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Adding property that already exists.");
             goto error;
         }
     } else if (d->mod == LY_DEVIATE_RPL) {
@@ -2063,11 +2070,11 @@
     /* check min-elements is smaller than max-elements */
     if (*max && *min > *max) {
         if (type) {
-            LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, "max-elements");
-            LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "\"max-elements\" is smaller than \"min-elements\".");
+            LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, "max-elements");
+            LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "\"max-elements\" is smaller than \"min-elements\".");
         } else {
-            LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, "min-elements");
-            LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "\"min-elements\" is bigger than \"max-elements\".");
+            LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, "min-elements");
+            LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "\"min-elements\" is bigger than \"max-elements\".");
         }
         goto error;
     }
@@ -2075,7 +2082,6 @@
     return EXIT_SUCCESS;
 
 error:
-
     return EXIT_FAILURE;
 }
 
@@ -2090,7 +2096,7 @@
     int f_min = 0, f_max = 0; /* flags */
     int i, j, k, rc;
     unsigned int u;
-    struct ly_ctx *ctx;
+    struct ly_ctx *ctx = module->ctx;
     struct lys_deviate *d = NULL;
     struct lys_node *node = NULL, *parent, *dev_target = NULL;
     struct lys_node_choice *choice = NULL;
@@ -2105,9 +2111,7 @@
     struct lys_module *mod;
     void *reallocated;
 
-    ctx = module->ctx;
-
-    GETVAL(value, yin, "target-node");
+    GETVAL(ctx, value, yin, "target-node");
     dev->target_name = transform_schema2json(module, value);
     if (!dev->target_name) {
         goto error;
@@ -2116,7 +2120,7 @@
     /* resolve target node */
     rc = resolve_schema_nodeid(dev->target_name, NULL, module, &set, 0, 1);
     if (rc == -1) {
-        LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, dev->target_name, yin->name);
+        LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, dev->target_name, yin->name);
         ly_set_free(set);
         goto error;
     }
@@ -2124,8 +2128,8 @@
     ly_set_free(set);
 
     if (dev_target->module == lys_main_module(module)) {
-        LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, dev->target_name, yin->name);
-        LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Deviating own module is not allowed.");
+        LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, dev->target_name, yin->name);
+        LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Deviating own module is not allowed.");
         goto error;
     }
 
@@ -2136,12 +2140,12 @@
             continue;
         } else if (strcmp(child->ns->value, LY_NSYIN)) {
             /* extension */
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ext, dev->ext_size, "extensions", "deviation", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ext, dev->ext_size, "extensions", "deviation", error);
             c_ext++;
             continue;
         } else if (!strcmp(child->name, "description")) {
             if (dev->dsc) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
                 goto error;
             }
             if (lyp_yin_parse_subnode_ext(module, dev, LYEXT_PAR_DEVIATION, child, LYEXT_SUBSTMT_DESCRIPTION, 0, unres)) {
@@ -2153,7 +2157,7 @@
             }
         } else if (!strcmp(child->name, "reference")) {
             if (dev->ref) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
                 goto error;
             }
             if (lyp_yin_parse_subnode_ext(module, dev, LYEXT_PAR_DEVIATION, child, LYEXT_SUBSTMT_REFERENCE, 0, unres)) {
@@ -2164,7 +2168,7 @@
                 goto error;
             }
         } else if (!strcmp(child->name, "deviate")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_dev, dev->deviate_size, "deviates", "deviation", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_dev, dev->deviate_size, "deviates", "deviation", error);
             c_dev++;
 
             /* skip lyxml_free() at the end of the loop, node will be
@@ -2173,7 +2177,7 @@
             continue;
 
         } else {
-            LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
             goto error;
         }
 
@@ -2182,15 +2186,15 @@
 
     if (c_dev) {
         dev->deviate = calloc(c_dev, sizeof *dev->deviate);
-        LY_CHECK_ERR_GOTO(!dev->deviate, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!dev->deviate, LOGMEM(ctx), error);
     } else {
-        LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "deviate", "deviation");
+        LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "deviate", "deviation");
         goto error;
     }
     if (c_ext) {
         /* some extensions may be already present from the substatements */
         reallocated = realloc(dev->ext, (c_ext + dev->ext_size) * sizeof *dev->ext);
-        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM(ctx), error);
         dev->ext = reallocated;
 
         /* init memory */
@@ -2218,15 +2222,15 @@
         c_ext = 0;
 
         /* get deviation type */
-        GETVAL(value, develem, "value");
+        GETVAL(ctx, value, develem, "value");
         if (!strcmp(value, "not-supported")) {
             dev->deviate[dev->deviate_size].mod = LY_DEVIATE_NO;
             /* no other deviate statement is expected,
              * not-supported deviation must be the only deviation of the target
              */
             if (dev->deviate_size || develem->next) {
-                LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, develem->name);
-                LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "\"not-supported\" deviation cannot be combined with any other deviation.");
+                LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, develem->name);
+                LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "\"not-supported\" deviation cannot be combined with any other deviation.");
                 goto error;
             }
 
@@ -2234,8 +2238,8 @@
             if ((dev_target->nodetype == LYS_LEAF) && lys_parent(dev_target) && (lys_parent(dev_target)->nodetype == LYS_LIST)) {
                 for (i = 0; i < ((struct lys_node_list *)lys_parent(dev_target))->keys_size; ++i) {
                     if (((struct lys_node_list *)lys_parent(dev_target))->keys[i] == (struct lys_node_leaf *)dev_target) {
-                        LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, develem->name);
-                        LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "\"not-supported\" deviation cannot remove a list key.");
+                        LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, develem->name);
+                        LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "\"not-supported\" deviation cannot remove a list key.");
                         goto error;
                     }
                 }
@@ -2260,7 +2264,7 @@
         } else if (!strcmp(value, "delete")) {
             dev->deviate[dev->deviate_size].mod = LY_DEVIATE_DEL;
         } else {
-            LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, develem->name);
+            LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, develem->name);
             goto error;
         }
         d = &dev->deviate[dev->deviate_size];
@@ -2272,7 +2276,7 @@
             dev->orig_node = lys_node_dup(dev_target->module, NULL, dev_target, &tmp_unres, 1);
             /* just to be safe */
             if (tmp_unres.count) {
-                LOGINT;
+                LOGINT(ctx);
                 goto error;
             }
         }
@@ -2285,15 +2289,15 @@
                 continue;
             } else if  (strcmp(child->ns->value, LY_NSYIN)) {
                 /* extensions */
-                YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ext, d->ext_size, "extensions", "deviate", error);
+                YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ext, d->ext_size, "extensions", "deviate", error);
                 c_ext++;
             } else if (d->mod == LY_DEVIATE_NO) {
                 /* no YIN substatement expected in this case */
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
+                LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
                 goto error;
             } else if (!strcmp(child->name, "config")) {
                 if (d->flags & LYS_CONFIG_MASK) {
-                    LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
+                    LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
                     goto error;
                 }
 
@@ -2302,19 +2306,19 @@
                  * that config is specified in every node. But for delete, we check that the value
                  * is the same as here in deviation
                  */
-                GETVAL(value, child, "value");
+                GETVAL(ctx, value, child, "value");
                 if (!strcmp(value, "false")) {
                     d->flags |= LYS_CONFIG_R;
                 } else if (!strcmp(value, "true")) {
                     d->flags |= LYS_CONFIG_W;
                 } else {
-                    LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, child->name);
+                    LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, child->name);
                     goto error;
                 }
 
                 if (d->mod == LY_DEVIATE_DEL) {
                     /* del config is forbidden */
-                    LOGVAL(LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, "config", "deviate delete");
+                    LOGVAL(ctx, LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, "config", "deviate delete");
                     goto error;
                 } else { /* add and replace are the same in this case */
                     /* remove current config value of the target ... */
@@ -2331,21 +2335,21 @@
                 if (lyp_yin_parse_subnode_ext(module, d, LYEXT_PAR_DEVIATE, child, LYEXT_SUBSTMT_DEFAULT, c_dflt, unres)) {
                     goto error;
                 }
-                YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_dflt, d->dflt_size, "defaults", "deviate", error);
+                YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_dflt, d->dflt_size, "defaults", "deviate", error);
                 c_dflt++;
 
                 /* check target node type */
                 if (module->version < 2 && dev_target->nodetype == LYS_LEAFLIST) {
-                    LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, "default");
-                    LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Target node does not allow \"default\" property.");
+                    LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, "default");
+                    LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Target node does not allow \"default\" property.");
                     goto error;
                 } else if (c_dflt > 1 && dev_target->nodetype != LYS_LEAFLIST) { /* from YANG 1.1 */
-                    LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, "default");
-                    LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Target node does not allow multiple \"default\" properties.");
+                    LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, "default");
+                    LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Target node does not allow multiple \"default\" properties.");
                     goto error;
                 } else if (c_dflt == 1 && (!(dev_target->nodetype & (LYS_LEAF | LYS_LEAFLIST | LYS_CHOICE)))) {
-                    LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, "default");
-                    LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Target node does not allow \"default\" property.");
+                    LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, "default");
+                    LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Target node does not allow \"default\" property.");
                     goto error;
                 }
 
@@ -2354,32 +2358,32 @@
 
             } else if (!strcmp(child->name, "mandatory")) {
                 if (d->flags & LYS_MAND_MASK) {
-                    LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
+                    LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
                     goto error;
                 }
 
                 /* check target node type */
                 if (!(dev_target->nodetype & (LYS_LEAF | LYS_CHOICE | LYS_ANYDATA))) {
-                    LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
-                    LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Target node does not allow \"%s\" property.", child->name);
+                    LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
+                    LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Target node does not allow \"%s\" property.", child->name);
                     goto error;
                 }
 
-                GETVAL(value, child, "value");
+                GETVAL(ctx, value, child, "value");
                 if (!strcmp(value, "false")) {
                     d->flags |= LYS_MAND_FALSE;
                 } else if (!strcmp(value, "true")) {
                     d->flags |= LYS_MAND_TRUE;
                 } else {
-                    LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, child->name);
+                    LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, child->name);
                     goto error;
                 }
 
                 if (d->mod == LY_DEVIATE_ADD) {
                     /* check that there is no current value */
                     if (dev_target->flags & LYS_MAND_MASK) {
-                        LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
-                        LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Adding property that already exists.");
+                        LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
+                        LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Adding property that already exists.");
                         goto error;
                     }
 
@@ -2387,15 +2391,15 @@
                     if (d->flags & LYS_MAND_TRUE) {
                         if (dev_target->nodetype == LYS_CHOICE) {
                             if (((struct lys_node_choice *)(dev_target))->dflt) {
-                                LOGVAL(LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, child->name, child->parent->name);
-                                LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL,
+                                LOGVAL(ctx, LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, child->name, child->parent->name);
+                                LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL,
                                        "Adding the \"mandatory\" statement is forbidden on choice with the \"default\" statement.");
                                 goto error;
                             }
                         } else if (dev_target->nodetype == LYS_LEAF) {
                             if (((struct lys_node_leaf *)(dev_target))->dflt) {
-                                LOGVAL(LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, child->name, child->parent->name);
-                                LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL,
+                                LOGVAL(ctx, LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, child->name, child->parent->name);
+                                LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL,
                                        "Adding the \"mandatory\" statement is forbidden on leaf with the \"default\" statement.");
                                 goto error;
                             }
@@ -2406,8 +2410,8 @@
                 } else if (d->mod == LY_DEVIATE_RPL) {
                     /* check that there was a value before */
                     if (!(dev_target->flags & LYS_MAND_MASK)) {
-                        LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
-                        LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Replacing a property that does not exist.");
+                        LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
+                        LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Replacing a property that does not exist.");
                         goto error;
                     }
 
@@ -2415,7 +2419,7 @@
                     dev_target->flags |= d->flags & LYS_MAND_MASK;
                 } else if (d->mod == LY_DEVIATE_DEL) {
                     /* del mandatory is forbidden */
-                    LOGVAL(LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, "mandatory", "deviate delete");
+                    LOGVAL(ctx, LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, "mandatory", "deviate delete");
                     goto error;
                 }
 
@@ -2440,7 +2444,7 @@
                 }
             } else if (!strcmp(child->name, "min-elements")) {
                 if (f_min) {
-                    LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
+                    LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
                     goto error;
                 }
                 f_min = 1;
@@ -2453,7 +2457,7 @@
                 }
             } else if (!strcmp(child->name, "max-elements")) {
                 if (f_max) {
-                    LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
+                    LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
                     goto error;
                 }
                 f_max = 1;
@@ -2465,22 +2469,22 @@
                     goto error;
                 }
             } else if (!strcmp(child->name, "must")) {
-                YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_must, d->must_size, "musts", "deviate", error);
+                YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_must, d->must_size, "musts", "deviate", error);
                 c_must++;
                 /* skip lyxml_free() at the end of the loop, this node will be processed later */
                 continue;
             } else if (!strcmp(child->name, "type")) {
                 if (d->type) {
-                    LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
+                    LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
                     goto error;
                 }
 
                 /* add, del type is forbidden */
                 if (d->mod == LY_DEVIATE_ADD) {
-                    LOGVAL(LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, "type", "deviate add");
+                    LOGVAL(ctx, LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, "type", "deviate add");
                     goto error;
                 } else if (d->mod == LY_DEVIATE_DEL) {
-                    LOGVAL(LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, "type", "deviate delete");
+                    LOGVAL(ctx, LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, "type", "deviate delete");
                     goto error;
                 }
 
@@ -2496,8 +2500,8 @@
                         ly_set_add(dflt_check, dev_target, 0);
                     }
                 } else {
-                    LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
-                    LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Target node does not allow \"%s\" property.", child->name);
+                    LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
+                    LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Target node does not allow \"%s\" property.", child->name);
                     goto error;
                 }
 
@@ -2515,13 +2519,13 @@
                 if (lyp_yin_parse_subnode_ext(module, d, LYEXT_PAR_DEVIATE, child, LYEXT_SUBSTMT_UNIQUE, c_uniq, unres)) {
                     goto error;
                 }
-                YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_uniq, d->unique_size, "uniques", "deviate", error);
+                YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_uniq, d->unique_size, "uniques", "deviate", error);
                 c_uniq++;
                 /* skip lyxml_free() at the end of the loop, this node will be processed later */
                 continue;
             } else if (!strcmp(child->name, "units")) {
                 if (d->units) {
-                    LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
+                    LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
                     goto error;
                 }
 
@@ -2531,21 +2535,21 @@
                 } else if (dev_target->nodetype == LYS_LEAF) {
                     stritem = &((struct lys_node_leaf *)dev_target)->units;
                 } else {
-                    LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
-                    LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Target node does not allow \"%s\" property.", child->name);
+                    LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
+                    LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Target node does not allow \"%s\" property.", child->name);
                     goto error;
                 }
 
                 /* get units value */
-                GETVAL(value, child, "name");
+                GETVAL(ctx, value, child, "name");
                 d->units = lydict_insert(ctx, value, 0);
 
                 /* apply to target */
                 if (d->mod == LY_DEVIATE_ADD) {
                     /* check that there is no current value */
                     if (*stritem) {
-                        LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
-                        LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Adding property that already exists.");
+                        LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
+                        LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Adding property that already exists.");
                         goto error;
                     }
 
@@ -2553,8 +2557,8 @@
                 } else if (d->mod == LY_DEVIATE_RPL) {
                     /* check that there was a value before */
                     if (!*stritem) {
-                        LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
-                        LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Replacing a property that does not exist.");
+                        LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
+                        LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Replacing a property that does not exist.");
                         goto error;
                     }
 
@@ -2563,8 +2567,8 @@
                 } else if (d->mod == LY_DEVIATE_DEL) {
                     /* check values */
                     if (!ly_strequal(*stritem, d->units, 1)) {
-                        LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, child->name);
-                        LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Value differs from the target being deleted.");
+                        LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, child->name);
+                        LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Value differs from the target being deleted.");
                         goto error;
                     }
                     /* remove current units value of the target */
@@ -2583,7 +2587,7 @@
                     goto error;
                 }
             } else {
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
+                LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
                 goto error;
             }
 
@@ -2615,8 +2619,8 @@
                 trg_must_size = &((struct lys_node_anydata *)dev_target)->must_size;
                 break;
             default:
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, "must");
-                LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Target node does not allow \"must\" property.");
+                LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, "must");
+                LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Target node does not allow \"must\" property.");
                 goto error;
             }
 
@@ -2624,31 +2628,31 @@
 
             if (d->mod == LY_DEVIATE_RPL) {
                 /* replace must is forbidden */
-                LOGVAL(LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, "must", "deviate replace");
+                LOGVAL(ctx, LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, "must", "deviate replace");
                 goto error;
             } else if (d->mod == LY_DEVIATE_ADD) {
                 /* reallocate the must array of the target */
                 d->must = ly_realloc(*trg_must, (c_must + *trg_must_size) * sizeof *d->must);
-                LY_CHECK_ERR_GOTO(!d->must, LOGMEM, error);
+                LY_CHECK_ERR_GOTO(!d->must, LOGMEM(ctx), error);
                 *trg_must = d->must;
                 d->must = &((*trg_must)[*trg_must_size]);
                 d->must_size = c_must;
             } else { /* LY_DEVIATE_DEL */
                 d->must = calloc(c_must, sizeof *d->must);
             }
-            LY_CHECK_ERR_GOTO(!d->must, LOGMEM, error);
+            LY_CHECK_ERR_GOTO(!d->must, LOGMEM(ctx), error);
         }
         if (c_uniq) {
             /* replace unique is forbidden */
             if (d->mod == LY_DEVIATE_RPL) {
-                LOGVAL(LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, "unique", "deviate replace");
+                LOGVAL(ctx, LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, "unique", "deviate replace");
                 goto error;
             }
 
             /* check target node type */
             if (dev_target->nodetype != LYS_LIST) {
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, "unique");
-                LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Target node does not allow \"unique\" property.");
+                LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, "unique");
+                LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Target node does not allow \"unique\" property.");
                 goto error;
             }
 
@@ -2656,13 +2660,13 @@
             if (d->mod == LY_DEVIATE_ADD) {
                 /* reallocate the unique array of the target */
                 d->unique = ly_realloc(list->unique, (c_uniq + list->unique_size) * sizeof *d->unique);
-                LY_CHECK_ERR_GOTO(!d->unique, LOGMEM, error);
+                LY_CHECK_ERR_GOTO(!d->unique, LOGMEM(ctx), error);
                 list->unique = d->unique;
                 d->unique = &list->unique[list->unique_size];
                 d->unique_size = c_uniq;
             } else { /* LY_DEVIATE_DEL */
                 d->unique = calloc(c_uniq, sizeof *d->unique);
-                LY_CHECK_ERR_GOTO(!d->unique, LOGMEM, error);
+                LY_CHECK_ERR_GOTO(!d->unique, LOGMEM(ctx), error);
             }
         }
         if (c_dflt) {
@@ -2670,16 +2674,16 @@
                 /* check that there is no current value */
                 if ((dev_target->nodetype == LYS_LEAF && ((struct lys_node_leaf *)dev_target)->dflt) ||
                         (dev_target->nodetype == LYS_CHOICE && ((struct lys_node_choice *)dev_target)->dflt)) {
-                    LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, "default");
-                    LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Adding property that already exists.");
+                    LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, "default");
+                    LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Adding property that already exists.");
                     goto error;
                 }
 
                 /* check collision with mandatory/min-elements */
                 if ((dev_target->flags & LYS_MAND_TRUE) ||
                         (dev_target->nodetype == LYS_LEAFLIST && ((struct lys_node_leaflist *)dev_target)->min)) {
-                    LOGVAL(LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, child->name, child->parent->name);
-                    LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL,
+                    LOGVAL(ctx, LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, child->name, child->parent->name);
+                    LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL,
                            "Adding the \"default\" statement is forbidden on %s statement.",
                            (dev_target->flags & LYS_MAND_TRUE) ? "nodes with the \"mandatory\"" : "leaflists with non-zero \"min-elements\"");
                     goto error;
@@ -2688,8 +2692,8 @@
                 /* check that there was a value before */
                 if (((dev_target->nodetype & (LYS_LEAF | LYS_LEAFLIST)) && !((struct lys_node_leaf *)dev_target)->dflt) ||
                         (dev_target->nodetype == LYS_CHOICE && !((struct lys_node_choice *)dev_target)->dflt)) {
-                    LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
-                    LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Replacing a property that does not exist.");
+                    LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
+                    LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Replacing a property that does not exist.");
                     goto error;
                 }
             }
@@ -2700,24 +2704,24 @@
                 if (d->mod == LY_DEVIATE_ADD) {
                     /* reallocate (enlarge) the unique array of the target */
                     llist->dflt = ly_realloc(llist->dflt, (c_dflt + llist->dflt_size) * sizeof *d->dflt);
-                    LY_CHECK_ERR_GOTO(!llist->dflt, LOGMEM, error);
+                    LY_CHECK_ERR_GOTO(!llist->dflt, LOGMEM(ctx), error);
                 } else if (d->mod == LY_DEVIATE_RPL) {
                     /* reallocate (replace) the unique array of the target */
                     for (i = 0; i < llist->dflt_size; i++) {
-                        lydict_remove(llist->module->ctx, llist->dflt[i]);
+                        lydict_remove(ctx, llist->dflt[i]);
                     }
                     llist->dflt = ly_realloc(llist->dflt, c_dflt * sizeof *d->dflt);
                     llist->dflt_size = 0;
-                    LY_CHECK_ERR_GOTO(!llist->dflt, LOGMEM, error);
+                    LY_CHECK_ERR_GOTO(!llist->dflt, LOGMEM(ctx), error);
                 }
             }
             d->dflt = calloc(c_dflt, sizeof *d->dflt);
-            LY_CHECK_ERR_GOTO(!d->dflt, LOGMEM, error);
+            LY_CHECK_ERR_GOTO(!d->dflt, LOGMEM(ctx), error);
         }
         if (c_ext) {
             /* some extensions may be already present from the substatements */
             reallocated = realloc(d->ext, (c_ext + d->ext_size) * sizeof *d->ext);
-            LY_CHECK_ERR_GOTO(!reallocated, LOGMEM, error);
+            LY_CHECK_ERR_GOTO(!reallocated, LOGMEM(ctx), error);
             d->ext = reallocated;
 
             /* init memory */
@@ -2770,9 +2774,9 @@
                     d->must_size++;
                     if (i != -1) {
                         /* no match found */
-                        LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL,
+                        LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL,
                                d->must[d->must_size - 1].expr, child->name);
-                        LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Value does not match any must from the target.");
+                        LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Value does not match any must from the target.");
                         goto error;
                     }
                 } else { /* replace or add */
@@ -2838,8 +2842,8 @@
                     d->unique_size++;
                     if (i != -1) {
                         /* no match found */
-                        LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, lyxml_get_attr(child, "tag", NULL), child->name);
-                        LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Value differs from the target being deleted.");
+                        LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, lyxml_get_attr(child, "tag", NULL), child->name);
+                        LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Value differs from the target being deleted.");
                         goto error;
                     }
 
@@ -2863,21 +2867,21 @@
                     }
                 }
             } else if (!strcmp(child->name, "default")) {
-                GETVAL(value, child, "value");
+                GETVAL(ctx, value, child, "value");
                 u = strlen(value);
-                d->dflt[d->dflt_size++] = lydict_insert(module->ctx, value, u);
+                d->dflt[d->dflt_size++] = lydict_insert(ctx, value, u);
 
                 if (dev_target->nodetype == LYS_CHOICE) {
                     choice = (struct lys_node_choice *)dev_target;
                     rc = resolve_choice_default_schema_nodeid(value, choice->child, (const struct lys_node **)&node);
                     if (rc || !node) {
-                        LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, "default");
+                        LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, "default");
                         goto error;
                     }
                     if (d->mod == LY_DEVIATE_DEL) {
                         if (!choice->dflt || (choice->dflt != node)) {
-                            LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, "default");
-                            LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Value differs from the target being deleted.");
+                            LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, "default");
+                            LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Value differs from the target being deleted.");
                             goto error;
                         }
                         choice->dflt = NULL;
@@ -2891,7 +2895,7 @@
                         choice->dflt = node;
                         if (!choice->dflt) {
                             /* default branch not found */
-                            LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, "default");
+                            LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, "default");
                             goto error;
                         }
                     }
@@ -2899,8 +2903,8 @@
                     leaf = (struct lys_node_leaf *)dev_target;
                     if (d->mod == LY_DEVIATE_DEL) {
                         if (!leaf->dflt || !ly_strequal(leaf->dflt, value, 1)) {
-                            LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, "default");
-                            LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Value differs from the target being deleted.");
+                            LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, "default");
+                            LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Value differs from the target being deleted.");
                             goto error;
                         }
                         /* remove value */
@@ -2932,7 +2936,7 @@
                         for (i = 0; i < llist->dflt_size; i++) {
                             if (llist->dflt[i] && ly_strequal(llist->dflt[i], value, 1)) {
                                 /* match, remove the value */
-                                lydict_remove(llist->module->ctx, llist->dflt[i]);
+                                lydict_remove(ctx, llist->dflt[i]);
                                 llist->dflt[i] = NULL;
 
                                 /* remove extensions of this default instance from the target node */
@@ -2950,8 +2954,8 @@
                             }
                         }
                         if (i == llist->dflt_size) {
-                            LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, "default");
-                            LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "The default value to delete not found in the target node.");
+                            LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, "default");
+                            LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "The default value to delete not found in the target node.");
                             goto error;
                         }
                     } else {
@@ -2960,13 +2964,13 @@
                         /* we just want to check that the value isn't already in the list */
                         for (i = 0; i < llist->dflt_size; i++) {
                             if (ly_strequal(llist->dflt[i], value, 1)) {
-                                LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, "default");
-                                LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Duplicated default value \"%s\".", value);
+                                LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, "default");
+                                LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Duplicated default value \"%s\".", value);
                                 goto error;
                             }
                         }
                         /* store it in target node */
-                        llist->dflt[llist->dflt_size++] = lydict_insert(module->ctx, value, u);
+                        llist->dflt[llist->dflt_size++] = lydict_insert(ctx, value, u);
 
                         /* remember to check it later (it may not fit now, but the type can be deviated too) */
                         ly_set_add(dflt_check, dev_target, 0);
@@ -2990,7 +2994,7 @@
     }
 
     /* now check whether default value, if any, matches the type */
-    if (!(module->ctx->models.flags & LY_CTX_TRUSTED)) {
+    if (!(ctx->models.flags & LY_CTX_TRUSTED)) {
         for (u = 0; u < dflt_check->number; ++u) {
             value = NULL;
             rc = EXIT_SUCCESS;
@@ -3011,8 +3015,8 @@
 
             }
             if (rc == -1) {
-                LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, "default");
-                LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL,
+                LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, "default");
+                LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL,
                     "The default value \"%s\" of the deviated node \"%s\" no longer matches its type.",
                     dev->target_name);
                 goto error;
@@ -3027,7 +3031,7 @@
             mod->deviated = 1;            /* main module */
             parent->module->deviated = 1; /* possible submodule */
             if (lys_set_implemented(mod)) {
-                LOGERR(ly_errno, "Setting the deviated module \"%s\" implemented failed.", mod->name);
+                LOGERR(ctx, ly_errno, "Setting the deviated module \"%s\" implemented failed.", mod->name);
                 goto error;
             }
         }
@@ -3046,6 +3050,7 @@
 fill_yin_augment(struct lys_module *module, struct lys_node *parent, struct lyxml_elem *yin, struct lys_node_augment *aug,
                  int options, struct unres_schema *unres)
 {
+    struct ly_ctx *ctx = module->ctx;
     const char *value;
     struct lyxml_elem *sub, *next;
     struct lys_node *node;
@@ -3053,7 +3058,7 @@
     void *reallocated;
 
     aug->nodetype = LYS_AUGMENT;
-    GETVAL(value, yin, "target-node");
+    GETVAL(ctx, value, yin, "target-node");
     aug->target_name = transform_schema2json(module, value);
     if (!aug->target_name) {
         goto error;
@@ -3067,25 +3072,25 @@
     LY_TREE_FOR_SAFE(yin->child, next, sub) {
         if (strcmp(sub->ns->value, LY_NSYIN)) {
             /* extension */
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ext, aug->ext_size, "extensions", "augment", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ext, aug->ext_size, "extensions", "augment", error);
             c_ext++;
             continue;
         } else if (!strcmp(sub->name, "if-feature")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ftrs, aug->iffeature_size, "if-features", "augment", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ftrs, aug->iffeature_size, "if-features", "augment", error);
             c_ftrs++;
             continue;
         } else if (!strcmp(sub->name, "when")) {
             if (aug->when) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, sub->name, yin->name);
                 goto error;
             }
 
             aug->when = read_yin_when(module, sub, unres);
             if (!aug->when) {
-                lyxml_free(module->ctx, sub);
+                lyxml_free(ctx, sub);
                 goto error;
             }
-            lyxml_free(module->ctx, sub);
+            lyxml_free(ctx, sub);
             continue;
 
         /* check allowed data sub-statements */
@@ -3112,7 +3117,7 @@
         } else if (!strcmp(sub->name, "notification")) {
             node = read_yin_notif(module, (struct lys_node *)aug, sub, options, unres);
         } else {
-            LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, sub->name);
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, sub->name);
             goto error;
         }
 
@@ -3121,17 +3126,17 @@
         }
 
         node = NULL;
-        lyxml_free(module->ctx, sub);
+        lyxml_free(ctx, sub);
     }
 
     if (c_ftrs) {
         aug->iffeature = calloc(c_ftrs, sizeof *aug->iffeature);
-        LY_CHECK_ERR_GOTO(!aug->iffeature, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!aug->iffeature, LOGMEM(ctx), error);
     }
     if (c_ext) {
         /* some extensions may be already present from the substatements */
         reallocated = realloc(aug->ext, (c_ext + aug->ext_size) * sizeof *aug->ext);
-        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM(ctx), error);
         aug->ext = reallocated;
 
         /* init memory */
@@ -3152,7 +3157,7 @@
             if (ret) {
                 goto error;
             }
-            lyxml_free(module->ctx, sub);
+            lyxml_free(ctx, sub);
         }
     }
 
@@ -3169,7 +3174,7 @@
     }
 
     /* check XPath dependencies */
-    if (!(module->ctx->models.flags & LY_CTX_TRUSTED) && aug->when) {
+    if (!(ctx->models.flags & LY_CTX_TRUSTED) && aug->when) {
         if (options & LYS_PARSE_OPT_INGRP) {
             if (lyxp_node_check_syntax((struct lys_node *)aug)) {
                 goto error;
@@ -3184,7 +3189,6 @@
     return EXIT_SUCCESS;
 
 error:
-
     return EXIT_FAILURE;
 }
 
@@ -3192,6 +3196,7 @@
 static int
 fill_yin_refine(struct lys_node *uses, struct lyxml_elem *yin, struct lys_refine *rfn, struct unres_schema *unres)
 {
+    struct ly_ctx *ctx = uses->module->ctx;
     struct lys_module *module;
     struct lyxml_elem *sub, *next;
     const char *value;
@@ -3205,7 +3210,7 @@
     assert(uses);
     module = uses->module; /* shorthand */
 
-    GETVAL(value, yin, "target-node");
+    GETVAL(ctx, value, yin, "target-node");
     rfn->target_name = transform_schema2json(module, value);
     if (!rfn->target_name) {
         goto error;
@@ -3216,13 +3221,13 @@
             /* garbage */
         } else if (strcmp(sub->ns->value, LY_NSYIN)) {
             /* extension */
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ext, rfn->ext_size, "extensions", "refine", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ext, rfn->ext_size, "extensions", "refine", error);
             c_ext++;
             continue;
 
         } else if (!strcmp(sub->name, "description")) {
             if (rfn->dsc) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, sub->name, yin->name);
                 goto error;
             }
 
@@ -3230,13 +3235,13 @@
                 goto error;
             }
 
-            rfn->dsc = read_yin_subnode(module->ctx, sub, "text");
+            rfn->dsc = read_yin_subnode(ctx, sub, "text");
             if (!rfn->dsc) {
                 goto error;
             }
         } else if (!strcmp(sub->name, "reference")) {
             if (rfn->ref) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, sub->name, yin->name);
                 goto error;
             }
 
@@ -3244,22 +3249,22 @@
                 goto error;
             }
 
-            rfn->ref = read_yin_subnode(module->ctx, sub, "text");
+            rfn->ref = read_yin_subnode(ctx, sub, "text");
             if (!rfn->ref) {
                 goto error;
             }
         } else if (!strcmp(sub->name, "config")) {
             if (rfn->flags & LYS_CONFIG_MASK) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, sub->name, yin->name);
                 goto error;
             }
-            GETVAL(value, sub, "value");
+            GETVAL(ctx, value, sub, "value");
             if (!strcmp(value, "false")) {
                 rfn->flags |= LYS_CONFIG_R;
             } else if (!strcmp(value, "true")) {
                 rfn->flags |= LYS_CONFIG_W;
             } else {
-                LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, sub->name);
+                LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, sub->name);
                 goto error;
             }
             rfn->flags |= LYS_CONFIG_SET;
@@ -3275,7 +3280,7 @@
                 if (c_dflt) {
                     /* multiple defaults are allowed only in leaf-list */
                     if (module->version < 2) {
-                        LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, sub->name, yin->name);
+                        LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, sub->name, yin->name);
                         goto error;
                     }
                     rfn->target_type &= LYS_LEAFLIST;
@@ -3288,8 +3293,8 @@
                     }
                 }
                 if (!rfn->target_type) {
-                    LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, sub->name, yin->name);
-                    LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Invalid refine target nodetype for the substatements.");
+                    LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, sub->name, yin->name);
+                    LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Invalid refine target nodetype for the substatements.");
                     goto error;
                 }
             } else {
@@ -3301,7 +3306,7 @@
                 }
             }
 
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_dflt, rfn->dflt_size, "defaults", "refine", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_dflt, rfn->dflt_size, "defaults", "refine", error);
             if (lyp_yin_parse_subnode_ext(module, rfn, LYEXT_PAR_REFINE, sub, LYEXT_SUBSTMT_DEFAULT, c_dflt, unres)) {
                 goto error;
             }
@@ -3310,7 +3315,7 @@
         } else if (!strcmp(sub->name, "mandatory")) {
             /* leaf, choice or anyxml */
             if (f_mand) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, sub->name, yin->name);
                 goto error;
             }
             /* just checking the flags in leaf is not sufficient, we would allow
@@ -3322,21 +3327,21 @@
             if (rfn->target_type) {
                 rfn->target_type &= (LYS_LEAF | LYS_CHOICE | LYS_ANYDATA);
                 if (!rfn->target_type) {
-                    LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, sub->name, yin->name);
-                    LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Invalid refine target nodetype for the substatements.");
+                    LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, sub->name, yin->name);
+                    LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Invalid refine target nodetype for the substatements.");
                     goto error;
                 }
             } else {
                 rfn->target_type = LYS_LEAF | LYS_CHOICE | LYS_ANYDATA;
             }
 
-            GETVAL(value, sub, "value");
+            GETVAL(ctx, value, sub, "value");
             if (!strcmp(value, "true")) {
                 rfn->flags |= LYS_MAND_TRUE;
             } else if (!strcmp(value, "false")) {
                 rfn->flags |= LYS_MAND_FALSE;
             } else {
-                LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, sub->name);
+                LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, sub->name);
                 goto error;
             }
             if (lyp_yin_parse_subnode_ext(module, rfn, LYEXT_PAR_REFINE, sub, LYEXT_SUBSTMT_MANDATORY, 0, unres)) {
@@ -3345,7 +3350,7 @@
         } else if (!strcmp(sub->name, "min-elements")) {
             /* list or leaf-list */
             if (f_min) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, sub->name, yin->name);
                 goto error;
             }
             f_min = 1;
@@ -3354,15 +3359,15 @@
             if (rfn->target_type) {
                 rfn->target_type &= (LYS_LIST | LYS_LEAFLIST);
                 if (!rfn->target_type) {
-                    LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, sub->name, yin->name);
-                    LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Invalid refine target nodetype for the substatements.");
+                    LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, sub->name, yin->name);
+                    LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Invalid refine target nodetype for the substatements.");
                     goto error;
                 }
             } else {
                 rfn->target_type = LYS_LIST | LYS_LEAFLIST;
             }
 
-            GETVAL(value, sub, "value");
+            GETVAL(ctx, value, sub, "value");
             while (isspace(value[0])) {
                 value++;
             }
@@ -3372,7 +3377,7 @@
             endptr = NULL;
             val = strtoul(value, &endptr, 10);
             if (*endptr || value[0] == '-' || errno || val > UINT32_MAX) {
-                LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, sub->name);
+                LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, sub->name);
                 goto error;
             }
             rfn->mod.list.min = (uint32_t) val;
@@ -3384,7 +3389,7 @@
         } else if (!strcmp(sub->name, "max-elements")) {
             /* list or leaf-list */
             if (f_max) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, sub->name, yin->name);
                 goto error;
             }
             f_max = 1;
@@ -3393,15 +3398,15 @@
             if (rfn->target_type) {
                 rfn->target_type &= (LYS_LIST | LYS_LEAFLIST);
                 if (!rfn->target_type) {
-                    LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, sub->name, yin->name);
-                    LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Invalid refine target nodetype for the substatements.");
+                    LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, sub->name, yin->name);
+                    LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Invalid refine target nodetype for the substatements.");
                     goto error;
                 }
             } else {
                 rfn->target_type = LYS_LIST | LYS_LEAFLIST;
             }
 
-            GETVAL(value, sub, "value");
+            GETVAL(ctx, value, sub, "value");
             while (isspace(value[0])) {
                 value++;
             }
@@ -3414,7 +3419,7 @@
                 endptr = NULL;
                 val = strtoul(value, &endptr, 10);
                 if (*endptr || value[0] == '-' || errno || val == 0 || val > UINT32_MAX) {
-                    LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, sub->name);
+                    LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, sub->name);
                     goto error;
                 }
                 rfn->mod.list.max = (uint32_t) val;
@@ -3427,7 +3432,7 @@
         } else if (!strcmp(sub->name, "presence")) {
             /* container */
             if (rfn->mod.presence) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, sub->name, yin->name);
                 goto error;
             }
 
@@ -3435,16 +3440,16 @@
             if (rfn->target_type) {
                 rfn->target_type &= LYS_CONTAINER;
                 if (!rfn->target_type) {
-                    LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, sub->name, yin->name);
-                    LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Invalid refine target nodetype for the substatements.");
+                    LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, sub->name, yin->name);
+                    LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Invalid refine target nodetype for the substatements.");
                     goto error;
                 }
             } else {
                 rfn->target_type = LYS_CONTAINER;
             }
 
-            GETVAL(value, sub, "value");
-            rfn->mod.presence = lydict_insert(module->ctx, value, strlen(value));
+            GETVAL(ctx, value, sub, "value");
+            rfn->mod.presence = lydict_insert(ctx, value, strlen(value));
 
             if (lyp_yin_parse_subnode_ext(module, rfn, LYEXT_PAR_REFINE, sub, LYEXT_SUBSTMT_PRESENCE, 0, unres)) {
                 goto error;
@@ -3455,15 +3460,15 @@
             if (rfn->target_type) {
                 rfn->target_type &= (LYS_LEAF | LYS_LIST | LYS_LEAFLIST | LYS_CONTAINER | LYS_ANYDATA);
                 if (!rfn->target_type) {
-                    LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, sub->name, yin->name);
-                    LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Invalid refine target nodetype for the substatements.");
+                    LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, sub->name, yin->name);
+                    LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Invalid refine target nodetype for the substatements.");
                     goto error;
                 }
             } else {
                 rfn->target_type = LYS_LEAF | LYS_LIST | LYS_LEAFLIST | LYS_CONTAINER | LYS_ANYDATA;
             }
 
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_must, rfn->must_size, "musts", "refine", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_must, rfn->must_size, "musts", "refine", error);
             c_must++;
             continue;
 
@@ -3473,42 +3478,42 @@
             if (rfn->target_type) {
                 rfn->target_type &= (LYS_LEAF | LYS_LIST | LYS_LEAFLIST | LYS_CONTAINER | LYS_ANYDATA);
                 if (!rfn->target_type) {
-                    LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, sub->name, yin->name);
-                    LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Invalid refine target nodetype for the substatements.");
+                    LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, sub->name, yin->name);
+                    LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Invalid refine target nodetype for the substatements.");
                     goto error;
                 }
             } else {
                 rfn->target_type = LYS_LEAF | LYS_LIST | LYS_LEAFLIST | LYS_CONTAINER | LYS_ANYDATA;
             }
 
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ftrs, rfn->iffeature_size, "if-feature", "refine", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ftrs, rfn->iffeature_size, "if-feature", "refine", error);
             c_ftrs++;
             continue;
         } else {
-            LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, sub->name);
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, sub->name);
             goto error;
         }
 
-        lyxml_free(module->ctx, sub);
+        lyxml_free(ctx, sub);
     }
 
     /* process nodes with cardinality of 0..n */
     if (c_must) {
         rfn->must = calloc(c_must, sizeof *rfn->must);
-        LY_CHECK_ERR_GOTO(!rfn->must, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!rfn->must, LOGMEM(ctx), error);
     }
     if (c_ftrs) {
         rfn->iffeature = calloc(c_ftrs, sizeof *rfn->iffeature);
-        LY_CHECK_ERR_GOTO(!rfn->iffeature, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!rfn->iffeature, LOGMEM(ctx), error);
     }
     if (c_dflt) {
         rfn->dflt = calloc(c_dflt, sizeof *rfn->dflt);
-        LY_CHECK_ERR_GOTO(!rfn->dflt, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!rfn->dflt, LOGMEM(ctx), error);
     }
     if (c_ext) {
         /* some extensions may be already present from the substatements */
         reallocated = realloc(rfn->ext, (c_ext + rfn->ext_size) * sizeof *rfn->ext);
-        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM(ctx), error);
         rfn->ext = reallocated;
 
         /* init memory */
@@ -3536,24 +3541,23 @@
                 goto error;
             }
         } else { /* default */
-            GETVAL(value, sub, "value");
+            GETVAL(ctx, value, sub, "value");
 
             /* check for duplicity */
             for (r = 0; r < rfn->dflt_size; r++) {
                 if (ly_strequal(rfn->dflt[r], value, 1)) {
-                    LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, "default");
-                    LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Duplicated default value \"%s\".", value);
+                    LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, "default");
+                    LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Duplicated default value \"%s\".", value);
                     goto error;
                 }
             }
-            rfn->dflt[rfn->dflt_size++] = lydict_insert(module->ctx, value, strlen(value));
+            rfn->dflt[rfn->dflt_size++] = lydict_insert(ctx, value, strlen(value));
         }
     }
 
     return EXIT_SUCCESS;
 
 error:
-
     return EXIT_FAILURE;
 }
 
@@ -3561,6 +3565,7 @@
 static int
 fill_yin_import(struct lys_module *module, struct lyxml_elem *yin, struct lys_import *imp, struct unres_schema *unres)
 {
+    struct ly_ctx *ctx = module->ctx;
     struct lyxml_elem *child, *next, exts;
     const char *value;
     int r, c_ext = 0;
@@ -3575,27 +3580,27 @@
             continue;
         } else if (strcmp(child->ns->value, LY_NSYIN)) {
             /* extension */
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ext, imp->ext_size, "extensions", "import", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ext, imp->ext_size, "extensions", "import", error);
             c_ext++;
-            lyxml_unlink_elem(module->ctx, child, 2);
-            lyxml_add_child(module->ctx, &exts, child);
+            lyxml_unlink_elem(ctx, child, 2);
+            lyxml_add_child(ctx, &exts, child);
         } else if (!strcmp(child->name, "prefix")) {
-            GETVAL(value, child, "value");
-            if (lyp_check_identifier(value, LY_IDENT_PREFIX, module, NULL)) {
+            GETVAL(ctx, value, child, "value");
+            if (lyp_check_identifier(ctx, value, LY_IDENT_PREFIX, module, NULL)) {
                 goto error;
             }
-            imp->prefix = lydict_insert(module->ctx, value, strlen(value));
+            imp->prefix = lydict_insert(ctx, value, strlen(value));
 
             if (lyp_yin_parse_subnode_ext(module, imp, LYEXT_PAR_IMPORT, child, LYEXT_SUBSTMT_PREFIX, 0, unres)) {
                 goto error;
             }
         } else if (!strcmp(child->name, "revision-date")) {
             if (imp->rev[0]) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
                 goto error;
             }
-            GETVAL(value, child, "date");
-            if (lyp_check_date(value)) {
+            GETVAL(ctx, value, child, "date");
+            if (lyp_check_date(ctx, value)) {
                 goto error;
             }
             memcpy(imp->rev, value, LY_REV_SIZE - 1);
@@ -3605,37 +3610,37 @@
             }
         } else if ((module->version >= 2) && !strcmp(child->name, "description")) {
             if (imp->dsc) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
                 goto error;
             }
             if (lyp_yin_parse_subnode_ext(module, imp, LYEXT_PAR_IMPORT, child, LYEXT_SUBSTMT_DESCRIPTION, 0, unres)) {
                 goto error;
             }
-            imp->dsc = read_yin_subnode(module->ctx, child, "text");
+            imp->dsc = read_yin_subnode(ctx, child, "text");
             if (!imp->dsc) {
                 goto error;
             }
         } else if ((module->version >= 2) && !strcmp(child->name, "reference")) {
             if (imp->ref) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
                 goto error;
             }
             if (lyp_yin_parse_subnode_ext(module, imp, LYEXT_PAR_IMPORT, child, LYEXT_SUBSTMT_REFERENCE, 0, unres)) {
                 goto error;
             }
-            imp->ref = read_yin_subnode(module->ctx, child, "text");
+            imp->ref = read_yin_subnode(ctx, child, "text");
             if (!imp->ref) {
                 goto error;
             }
         } else {
-            LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
             goto error;
         }
     }
 
     /* check mandatory information */
     if (!imp->prefix) {
-        LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "prefix", yin->name);
+        LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "prefix", yin->name);
         goto error;
     }
 
@@ -3643,7 +3648,7 @@
     if (c_ext) {
         /* some extensions may be already present from the substatements */
         reallocated = realloc(imp->ext, (c_ext + imp->ext_size) * sizeof *imp->ext);
-        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM(ctx), error);
         imp->ext = reallocated;
 
         /* init memory */
@@ -3659,13 +3664,12 @@
         }
     }
 
-    GETVAL(value, yin, "module");
+    GETVAL(ctx, value, yin, "module");
     return lyp_check_import(module, value, imp);
 
 error:
-
     while (exts.child) {
-        lyxml_free(module->ctx, exts.child);
+        lyxml_free(ctx, exts.child);
     }
     return EXIT_FAILURE;
 }
@@ -3679,6 +3683,7 @@
 fill_yin_include(struct lys_module *module, struct lys_submodule *submodule, struct lyxml_elem *yin,
                  struct lys_include *inc, struct unres_schema *unres)
 {
+    struct ly_ctx *ctx = module->ctx;
     struct lyxml_elem *child, *next, exts;
     const char *value;
     int r, c_ext = 0;
@@ -3693,17 +3698,17 @@
             continue;
         } else if (strcmp(child->ns->value, LY_NSYIN)) {
             /* extension */
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ext, inc->ext_size, "extensions", "include", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ext, inc->ext_size, "extensions", "include", error);
             c_ext++;
-            lyxml_unlink_elem(module->ctx, child, 2);
-            lyxml_add_child(module->ctx, &exts, child);
+            lyxml_unlink_elem(ctx, child, 2);
+            lyxml_add_child(ctx, &exts, child);
         } else if (!strcmp(child->name, "revision-date")) {
             if (inc->rev[0]) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "revision-date", yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, "revision-date", yin->name);
                 goto error;
             }
-            GETVAL(value, child, "date");
-            if (lyp_check_date(value)) {
+            GETVAL(ctx, value, child, "date");
+            if (lyp_check_date(ctx, value)) {
                 goto error;
             }
             memcpy(inc->rev, value, LY_REV_SIZE - 1);
@@ -3713,30 +3718,30 @@
             }
         } else if ((module->version >= 2) && !strcmp(child->name, "description")) {
             if (inc->dsc) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
                 goto error;
             }
             if (lyp_yin_parse_subnode_ext(module, inc, LYEXT_PAR_INCLUDE, child, LYEXT_SUBSTMT_DESCRIPTION, 0, unres)) {
                 goto error;
             }
-            inc->dsc = read_yin_subnode(module->ctx, child, "text");
+            inc->dsc = read_yin_subnode(ctx, child, "text");
             if (!inc->dsc) {
                 goto error;
             }
         } else if ((module->version >= 2) && !strcmp(child->name, "reference")) {
             if (inc->ref) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
                 goto error;
             }
             if (lyp_yin_parse_subnode_ext(module, inc, LYEXT_PAR_INCLUDE, child, LYEXT_SUBSTMT_REFERENCE, 0, unres)) {
                 goto error;
             }
-            inc->ref = read_yin_subnode(module->ctx, child, "text");
+            inc->ref = read_yin_subnode(ctx, child, "text");
             if (!inc->ref) {
                 goto error;
             }
         } else {
-            LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
             goto error;
         }
     }
@@ -3745,7 +3750,7 @@
     if (c_ext) {
         /* some extensions may be already present from the substatements */
         reallocated = realloc(inc->ext, (c_ext + inc->ext_size) * sizeof *inc->ext);
-        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM(ctx), error);
         inc->ext = reallocated;
 
         /* init memory */
@@ -3761,11 +3766,10 @@
         }
     }
 
-    GETVAL(value, yin, "module");
+    GETVAL(ctx, value, yin, "module");
     return lyp_check_include(submodule ? (struct lys_module *)submodule : module, value, inc, unres);
 
 error:
-
     return -1;
 }
 
@@ -3790,8 +3794,8 @@
     }
 
     if (opt & OPT_IDENT) {
-        GETVAL(value, xmlnode, "name");
-        if (lyp_check_identifier(value, LY_IDENT_NAME, NULL, NULL)) {
+        GETVAL(ctx, value, xmlnode, "name");
+        if (lyp_check_identifier(ctx, value, LY_IDENT_NAME, NULL, NULL)) {
             goto error;
         }
         node->name = lydict_insert(ctx, value, strlen(value));
@@ -3811,7 +3815,7 @@
 
         if (!strcmp(sub->name, "description")) {
             if (node->dsc) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, sub->name, xmlnode->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, sub->name, xmlnode->name);
                 goto error;
             }
 
@@ -3825,7 +3829,7 @@
             }
         } else if (!strcmp(sub->name, "reference")) {
             if (node->ref) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, sub->name, xmlnode->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, sub->name, xmlnode->name);
                 goto error;
             }
 
@@ -3839,10 +3843,10 @@
             }
         } else if (!strcmp(sub->name, "status")) {
             if (node->flags & LYS_STATUS_MASK) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, sub->name, xmlnode->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, sub->name, xmlnode->name);
                 goto error;
             }
-            GETVAL(value, sub, "value");
+            GETVAL(ctx, value, sub, "value");
             if (!strcmp(value, "current")) {
                 node->flags |= LYS_STATUS_CURR;
             } else if (!strcmp(value, "deprecated")) {
@@ -3850,7 +3854,7 @@
             } else if (!strcmp(value, "obsolete")) {
                 node->flags |= LYS_STATUS_OBSLT;
             } else {
-                LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, sub->name);
+                LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, sub->name);
                 goto error;
             }
 
@@ -3860,16 +3864,16 @@
         } else if ((opt & (OPT_CFG_PARSE | OPT_CFG_IGNORE)) && !strcmp(sub->name, "config")) {
             if (opt & OPT_CFG_PARSE) {
                 if (node->flags & LYS_CONFIG_MASK) {
-                    LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, sub->name, xmlnode->name);
+                    LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, sub->name, xmlnode->name);
                     goto error;
                 }
-                GETVAL(value, sub, "value");
+                GETVAL(ctx, value, sub, "value");
                 if (!strcmp(value, "false")) {
                     node->flags |= LYS_CONFIG_R;
                 } else if (!strcmp(value, "true")) {
                     node->flags |= LYS_CONFIG_W;
                 } else {
-                    LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, sub->name);
+                    LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, sub->name);
                     goto error;
                 }
                 node->flags |= LYS_CONFIG_SET;
@@ -3909,7 +3913,8 @@
             } else {
                 str = lys_path(parent, LYS_PATH_FIRST_PREFIX);
             }
-            LOGWRN("Missing status in %s subtree (%s), inheriting.", parent->flags & LYS_STATUS_DEPRC ? "deprecated" : "obsolete", str);
+            LOGWRN(ctx, "Missing status in %s subtree (%s), inheriting.",
+                   parent->flags & LYS_STATUS_DEPRC ? "deprecated" : "obsolete", str);
             free(str);
             node->flags |= parent->flags & LYS_STATUS_MASK;
         } else if ((parent->flags & LYS_STATUS_MASK) > (node->flags & LYS_STATUS_MASK)) {
@@ -3917,11 +3922,11 @@
             switch (node->flags & LYS_STATUS_MASK) {
             case 0:
             case LYS_STATUS_CURR:
-                LOGVAL(LYE_INSTATUS, LY_VLOG_LYS, parent, "current", xmlnode->name, "is child of",
+                LOGVAL(ctx, LYE_INSTATUS, LY_VLOG_LYS, parent, "current", xmlnode->name, "is child of",
                        parent->flags & LYS_STATUS_DEPRC ? "deprecated" : "obsolete", parent->name);
                 break;
             case LYS_STATUS_DEPRC:
-                LOGVAL(LYE_INSTATUS, LY_VLOG_LYS, parent, "deprecated", xmlnode->name, "is child of",
+                LOGVAL(ctx, LYE_INSTATUS, LY_VLOG_LYS, parent, "deprecated", xmlnode->name, "is child of",
                        "obsolete", parent->name);
                 break;
             }
@@ -3932,7 +3937,6 @@
     return EXIT_SUCCESS;
 
 error:
-
     return EXIT_FAILURE;
 }
 
@@ -3940,14 +3944,15 @@
 static struct lys_when *
 read_yin_when(struct lys_module *module, struct lyxml_elem *yin, struct unres_schema *unres)
 {
+    struct ly_ctx *ctx = module->ctx;
     struct lys_when *retval = NULL;
     struct lyxml_elem *child, *next;
     const char *value;
 
     retval = calloc(1, sizeof *retval);
-    LY_CHECK_ERR_RETURN(!retval, LOGMEM, NULL);
+    LY_CHECK_ERR_RETURN(!retval, LOGMEM(ctx), NULL);
 
-    GETVAL(value, yin, "condition");
+    GETVAL(ctx, value, yin, "condition");
     retval->cond = transform_schema2json(module, value);
     if (!retval->cond) {
         goto error;
@@ -3964,7 +3969,7 @@
             }
         } else if (!strcmp(child->name, "description")) {
             if (retval->dsc) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
                 goto error;
             }
 
@@ -3972,13 +3977,13 @@
                 goto error;
             }
 
-            retval->dsc = read_yin_subnode(module->ctx, child, "text");
+            retval->dsc = read_yin_subnode(ctx, child, "text");
             if (!retval->dsc) {
                 goto error;
             }
         } else if (!strcmp(child->name, "reference")) {
             if (retval->ref) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
                 goto error;
             }
 
@@ -3986,12 +3991,12 @@
                 goto error;
             }
 
-            retval->ref = read_yin_subnode(module->ctx, child, "text");
+            retval->ref = read_yin_subnode(ctx, child, "text");
             if (!retval->ref) {
                 goto error;
             }
         } else {
-            LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
             goto error;
         }
     }
@@ -3999,8 +4004,7 @@
     return retval;
 
 error:
-
-    lys_when_free(module->ctx, retval, NULL);
+    lys_when_free(ctx, retval, NULL);
     return NULL;
 }
 
@@ -4009,6 +4013,7 @@
 read_yin_case(struct lys_module *module, struct lys_node *parent, struct lyxml_elem *yin, int options,
               struct unres_schema *unres)
 {
+    struct ly_ctx *ctx = module->ctx;
     struct lyxml_elem *sub, *next, root;
     struct lys_node_case *cs;
     struct lys_node *retval, *node = NULL;
@@ -4019,7 +4024,7 @@
     memset(&root, 0, sizeof root);
 
     cs = calloc(1, sizeof *cs);
-    LY_CHECK_ERR_RETURN(!cs, LOGMEM, NULL);
+    LY_CHECK_ERR_RETURN(!cs, LOGMEM(ctx), NULL);
     cs->nodetype = LYS_CASE;
     cs->prev = (struct lys_node *)cs;
     retval = (struct lys_node *)cs;
@@ -4040,7 +4045,7 @@
     LY_TREE_FOR_SAFE(yin->child, next, sub) {
         if (strcmp(sub->ns->value, LY_NSYIN)) {
             /* extension */
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ext, retval->ext_size, "extensions", "case", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ext, retval->ext_size, "extensions", "case", error);
             c_ext++;
         } else if (!strcmp(sub->name, "container") ||
                 !strcmp(sub->name, "leaf-list") ||
@@ -4051,14 +4056,14 @@
                 !strcmp(sub->name, "anyxml") ||
                 !strcmp(sub->name, "anydata")) {
 
-            lyxml_unlink_elem(module->ctx, sub, 2);
-            lyxml_add_child(module->ctx, &root, sub);
+            lyxml_unlink_elem(ctx, sub, 2);
+            lyxml_add_child(ctx, &root, sub);
         } else if (!strcmp(sub->name, "if-feature")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ftrs, retval->iffeature_size, "if-features", "case", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ftrs, retval->iffeature_size, "if-features", "case", error);
             c_ftrs++;
         } else if (!strcmp(sub->name, "when")) {
             if (cs->when) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
                 goto error;
             }
 
@@ -4067,21 +4072,21 @@
                 goto error;
             }
 
-            lyxml_free(module->ctx, sub);
+            lyxml_free(ctx, sub);
         } else {
-            LOGVAL(LYE_INSTMT, LY_VLOG_LYS, retval, sub->name);
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_LYS, retval, sub->name);
             goto error;
         }
     }
 
     if (c_ftrs) {
         cs->iffeature = calloc(c_ftrs, sizeof *cs->iffeature);
-        LY_CHECK_ERR_GOTO(!cs->iffeature, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!cs->iffeature, LOGMEM(ctx), error);
     }
     if (c_ext) {
         /* some extensions may be already present from the substatements */
         reallocated = realloc(retval->ext, (c_ext + retval->ext_size) * sizeof *retval->ext);
-        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM(ctx), error);
         retval->ext = reallocated;
 
         /* init memory */
@@ -4129,11 +4134,11 @@
             goto error;
         }
 
-        lyxml_free(module->ctx, sub);
+        lyxml_free(ctx, sub);
     }
 
     /* check XPath dependencies */
-    if (!(module->ctx->models.flags & LY_CTX_TRUSTED) && cs->when) {
+    if (!(ctx->models.flags & LY_CTX_TRUSTED) && cs->when) {
         if (options & LYS_PARSE_OPT_INGRP) {
             if (lyxp_node_check_syntax(retval)) {
                 goto error;
@@ -4148,9 +4153,8 @@
     return retval;
 
 error:
-
     while (root.child) {
-        lyxml_free(module->ctx, root.child);
+        lyxml_free(ctx, root.child);
     }
     lys_node_free(retval, NULL, 0);
 
@@ -4171,7 +4175,7 @@
     void *reallocated;
 
     choice = calloc(1, sizeof *choice);
-    LY_CHECK_ERR_RETURN(!choice, LOGMEM, NULL);
+    LY_CHECK_ERR_RETURN(!choice, LOGMEM(ctx), NULL);
 
     choice->nodetype = LYS_CHOICE;
     choice->prev = (struct lys_node *)choice;
@@ -4195,7 +4199,7 @@
     LY_TREE_FOR_SAFE(yin->child, next, sub) {
         if (strcmp(sub->ns->value, LY_NSYIN)) {
             /* extension */
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ext, retval->ext_size, "extensions", "choice", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ext, retval->ext_size, "extensions", "choice", error);
             c_ext++;
             /* keep it for later processing, skip lyxml_free() */
             continue;
@@ -4229,7 +4233,7 @@
             }
         } else if (!strcmp(sub->name, "default")) {
             if (dflt) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
                 goto error;
             }
 
@@ -4244,7 +4248,7 @@
 
         } else if (!strcmp(sub->name, "mandatory")) {
             if (f_mand) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
                 goto error;
             }
             /* just checking the flags in leaf is not sufficient, we would allow
@@ -4252,13 +4256,13 @@
              */
             f_mand = 1;
 
-            GETVAL(value, sub, "value");
+            GETVAL(ctx, value, sub, "value");
             if (!strcmp(value, "true")) {
                 choice->flags |= LYS_MAND_TRUE;
             } else if (!strcmp(value, "false")) {
                 choice->flags |= LYS_MAND_FALSE;
             } else {
-                LOGVAL(LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
+                LOGVAL(ctx, LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
                 goto error;
             }                   /* else false is the default value, so we can ignore it */
 
@@ -4267,7 +4271,7 @@
             }
         } else if (!strcmp(sub->name, "when")) {
             if (choice->when) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
                 goto error;
             }
 
@@ -4276,7 +4280,7 @@
                 goto error;
             }
         } else if (!strcmp(sub->name, "if-feature")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ftrs, retval->iffeature_size, "if-features", "choice", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ftrs, retval->iffeature_size, "if-features", "choice", error);
             c_ftrs++;
 
             /* skip lyxml_free() at the end of the loop, the sub node is processed later */
@@ -4286,7 +4290,7 @@
                 goto error;
             }
         } else {
-            LOGVAL(LYE_INSTMT, LY_VLOG_LYS, retval, sub->name);
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_LYS, retval, sub->name);
             goto error;
         }
 
@@ -4296,12 +4300,12 @@
 
     if (c_ftrs) {
         choice->iffeature = calloc(c_ftrs, sizeof *choice->iffeature);
-        LY_CHECK_ERR_GOTO(!choice->iffeature, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!choice->iffeature, LOGMEM(ctx), error);
     }
     if (c_ext) {
         /* some extensions may be already present from the substatements */
         reallocated = realloc(retval->ext, (c_ext + retval->ext_size) * sizeof *retval->ext);
-        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM(ctx), error);
         retval->ext = reallocated;
 
         /* init memory */
@@ -4327,14 +4331,14 @@
 
     /* check - default is prohibited in combination with mandatory */
     if (dflt && (choice->flags & LYS_MAND_TRUE)) {
-        LOGVAL(LYE_INCHILDSTMT, LY_VLOG_LYS, retval, "default", "choice");
-        LOGVAL(LYE_SPEC, LY_VLOG_PREV, NULL, "The \"default\" statement is forbidden on choices with \"mandatory\".");
+        LOGVAL(ctx, LYE_INCHILDSTMT, LY_VLOG_LYS, retval, "default", "choice");
+        LOGVAL(ctx, LYE_SPEC, LY_VLOG_PREV, NULL, "The \"default\" statement is forbidden on choices with \"mandatory\".");
         goto error;
     }
 
     /* link default with the case */
     if (dflt) {
-        GETVAL(value, dflt, "value");
+        GETVAL(ctx, value, dflt, "value");
         if (unres_schema_add_str(module, unres, choice, UNRES_CHOICE_DFLT, value) == -1) {
             goto error;
         }
@@ -4342,7 +4346,7 @@
     }
 
     /* check XPath dependencies */
-    if (!(module->ctx->models.flags & LY_CTX_TRUSTED) && choice->when) {
+    if (!(ctx->models.flags & LY_CTX_TRUSTED) && choice->when) {
         if (options & LYS_PARSE_OPT_INGRP) {
             if (lyxp_node_check_syntax(retval)) {
                 goto error;
@@ -4357,10 +4361,8 @@
     return retval;
 
 error:
-
     lyxml_free(ctx, dflt);
     lys_node_free(retval, NULL, 0);
-
     return NULL;
 }
 
@@ -4369,6 +4371,7 @@
 read_yin_anydata(struct lys_module *module, struct lys_node *parent, struct lyxml_elem *yin, LYS_NODE type,
                  int options, struct unres_schema *unres)
 {
+    struct ly_ctx *ctx = module->ctx;
     struct lys_node *retval;
     struct lys_node_anydata *anyxml;
     struct lyxml_elem *sub, *next;
@@ -4379,7 +4382,7 @@
     void *reallocated;
 
     anyxml = calloc(1, sizeof *anyxml);
-    LY_CHECK_ERR_RETURN(!anyxml, LOGMEM, NULL);
+    LY_CHECK_ERR_RETURN(!anyxml, LOGMEM(ctx), NULL);
 
     anyxml->nodetype = type;
     anyxml->prev = (struct lys_node *)anyxml;
@@ -4387,8 +4390,7 @@
 
     if (read_yin_common(module, parent, retval, LYEXT_PAR_NODE, yin,
             OPT_IDENT | OPT_MODULE | ((options & LYS_PARSE_OPT_CFG_IGNORE) ? OPT_CFG_IGNORE :
-                (options & LYS_PARSE_OPT_CFG_NOINHERIT) ? OPT_CFG_PARSE : OPT_CFG_PARSE | OPT_CFG_INHERIT),
-            unres)) {
+            (options & LYS_PARSE_OPT_CFG_NOINHERIT) ? OPT_CFG_PARSE : OPT_CFG_PARSE | OPT_CFG_INHERIT), unres)) {
         goto error;
     }
 
@@ -4402,11 +4404,11 @@
     LY_TREE_FOR_SAFE(yin->child, next, sub) {
         if (strcmp(sub->ns->value, LY_NSYIN)) {
             /* extension */
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ext, retval->ext_size, "extensions", "anydata", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ext, retval->ext_size, "extensions", "anydata", error);
             c_ext++;
         } else if (!strcmp(sub->name, "mandatory")) {
             if (f_mand) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
                 goto error;
             }
             /* just checking the flags in leaf is not sufficient, we would allow
@@ -4414,13 +4416,13 @@
              */
             f_mand = 1;
 
-            GETVAL(value, sub, "value");
+            GETVAL(ctx, value, sub, "value");
             if (!strcmp(value, "true")) {
                 anyxml->flags |= LYS_MAND_TRUE;
             } else if (!strcmp(value, "false")) {
                 anyxml->flags |= LYS_MAND_FALSE;
             } else {
-                LOGVAL(LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
+                LOGVAL(ctx, LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
                 goto error;
             }
             /* else false is the default value, so we can ignore it */
@@ -4428,28 +4430,28 @@
             if (lyp_yin_parse_subnode_ext(module, retval, LYEXT_PAR_NODE, sub, LYEXT_SUBSTMT_MANDATORY, 0, unres)) {
                 goto error;
             }
-            lyxml_free(module->ctx, sub);
+            lyxml_free(ctx, sub);
         } else if (!strcmp(sub->name, "when")) {
             if (anyxml->when) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
                 goto error;
             }
 
             anyxml->when = read_yin_when(module, sub, unres);
             if (!anyxml->when) {
-                lyxml_free(module->ctx, sub);
+                lyxml_free(ctx, sub);
                 goto error;
             }
-            lyxml_free(module->ctx, sub);
+            lyxml_free(ctx, sub);
         } else if (!strcmp(sub->name, "must")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_must, anyxml->must_size, "musts", "anydata", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_must, anyxml->must_size, "musts", "anydata", error);
             c_must++;
         } else if (!strcmp(sub->name, "if-feature")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ftrs, retval->iffeature_size, "if-features", "anydata", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ftrs, retval->iffeature_size, "if-features", "anydata", error);
             c_ftrs++;
 
         } else {
-            LOGVAL(LYE_INSTMT, LY_VLOG_LYS, retval, sub->name);
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_LYS, retval, sub->name);
             goto error;
         }
     }
@@ -4457,16 +4459,16 @@
     /* middle part - process nodes with cardinality of 0..n */
     if (c_must) {
         anyxml->must = calloc(c_must, sizeof *anyxml->must);
-        LY_CHECK_ERR_GOTO(!anyxml->must, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!anyxml->must, LOGMEM(ctx), error);
     }
     if (c_ftrs) {
         anyxml->iffeature = calloc(c_ftrs, sizeof *anyxml->iffeature);
-        LY_CHECK_ERR_GOTO(!anyxml->iffeature, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!anyxml->iffeature, LOGMEM(ctx), error);
     }
     if (c_ext) {
         /* some extensions may be already present from the substatements */
         reallocated = realloc(retval->ext, (c_ext + retval->ext_size) * sizeof *retval->ext);
-        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM(ctx), error);
         retval->ext = reallocated;
 
         /* init memory */
@@ -4497,7 +4499,7 @@
     }
 
     /* check XPath dependencies */
-    if (!(module->ctx->models.flags & LY_CTX_TRUSTED) && (anyxml->when || anyxml->must)) {
+    if (!(ctx->models.flags & LY_CTX_TRUSTED) && (anyxml->when || anyxml->must)) {
         if (options & LYS_PARSE_OPT_INGRP) {
             if (lyxp_node_check_syntax(retval)) {
                 goto error;
@@ -4512,9 +4514,7 @@
     return retval;
 
 error:
-
     lys_node_free(retval, NULL, 0);
-
     return NULL;
 }
 
@@ -4523,6 +4523,7 @@
 read_yin_leaf(struct lys_module *module, struct lys_node *parent, struct lyxml_elem *yin, int options,
               struct unres_schema *unres)
 {
+    struct ly_ctx *ctx = module->ctx;
     struct lys_node *retval;
     struct lys_node_leaf *leaf;
     struct lyxml_elem *sub, *next;
@@ -4532,7 +4533,7 @@
     void *reallocated;
 
     leaf = calloc(1, sizeof *leaf);
-    LY_CHECK_ERR_RETURN(!leaf, LOGMEM, NULL);
+    LY_CHECK_ERR_RETURN(!leaf, LOGMEM(ctx), NULL);
 
     leaf->nodetype = LYS_LEAF;
     leaf->prev = (struct lys_node *)leaf;
@@ -4555,12 +4556,12 @@
     LY_TREE_FOR_SAFE(yin->child, next, sub) {
         if (strcmp(sub->ns->value, LY_NSYIN)) {
             /* extension */
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ext, retval->ext_size, "extensions", "leaf", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ext, retval->ext_size, "extensions", "leaf", error);
             c_ext++;
             continue;
         } else if (!strcmp(sub->name, "type")) {
             if (has_type) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
                 goto error;
             }
             /* HACK for unres */
@@ -4571,29 +4572,29 @@
             has_type = 1;
         } else if (!strcmp(sub->name, "default")) {
             if (leaf->dflt) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
                 goto error;
             }
-            GETVAL(value, sub, "value");
-            leaf->dflt = lydict_insert(module->ctx, value, strlen(value));
+            GETVAL(ctx, value, sub, "value");
+            leaf->dflt = lydict_insert(ctx, value, strlen(value));
 
             if (lyp_yin_parse_subnode_ext(module, retval, LYEXT_PAR_NODE, sub, LYEXT_SUBSTMT_DEFAULT, 0, unres)) {
                 goto error;
             }
         } else if (!strcmp(sub->name, "units")) {
             if (leaf->units) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
                 goto error;
             }
-            GETVAL(value, sub, "name");
-            leaf->units = lydict_insert(module->ctx, value, strlen(value));
+            GETVAL(ctx, value, sub, "name");
+            leaf->units = lydict_insert(ctx, value, strlen(value));
 
             if (lyp_yin_parse_subnode_ext(module, retval, LYEXT_PAR_NODE, sub, LYEXT_SUBSTMT_UNITS, 0, unres)) {
                 goto error;
             }
         } else if (!strcmp(sub->name, "mandatory")) {
             if (f_mand) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
                 goto error;
             }
             /* just checking the flags in leaf is not sufficient, we would allow
@@ -4601,13 +4602,13 @@
              */
             f_mand = 1;
 
-            GETVAL(value, sub, "value");
+            GETVAL(ctx, value, sub, "value");
             if (!strcmp(value, "true")) {
                 leaf->flags |= LYS_MAND_TRUE;
             } else if (!strcmp(value, "false")) {
                 leaf->flags |= LYS_MAND_FALSE;
             } else {
-                LOGVAL(LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
+                LOGVAL(ctx, LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
                 goto error;
             }                   /* else false is the default value, so we can ignore it */
 
@@ -4616,7 +4617,7 @@
             }
         } else if (!strcmp(sub->name, "when")) {
             if (leaf->when) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
                 goto error;
             }
 
@@ -4626,16 +4627,16 @@
             }
 
         } else if (!strcmp(sub->name, "must")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_must, leaf->must_size, "musts", "leaf", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_must, leaf->must_size, "musts", "leaf", error);
             c_must++;
             continue;
         } else if (!strcmp(sub->name, "if-feature")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ftrs, retval->iffeature_size, "musts", "leaf", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ftrs, retval->iffeature_size, "musts", "leaf", error);
             c_ftrs++;
             continue;
 
         } else {
-            LOGVAL(LYE_INSTMT, LY_VLOG_LYS, retval, sub->name);
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_LYS, retval, sub->name);
             goto error;
         }
 
@@ -4644,12 +4645,12 @@
 
     /* check mandatory parameters */
     if (!has_type) {
-        LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_LYS, retval, "type", yin->name);
+        LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_LYS, retval, "type", yin->name);
         goto error;
     }
     if (leaf->dflt && (leaf->flags & LYS_MAND_TRUE)) {
-        LOGVAL(LYE_INCHILDSTMT, LY_VLOG_LYS, retval, "mandatory", "leaf");
-        LOGVAL(LYE_SPEC, LY_VLOG_PREV, NULL,
+        LOGVAL(ctx, LYE_INCHILDSTMT, LY_VLOG_LYS, retval, "mandatory", "leaf");
+        LOGVAL(ctx, LYE_SPEC, LY_VLOG_PREV, NULL,
                "The \"mandatory\" statement is forbidden on leaf with the \"default\" statement.");
         goto error;
     }
@@ -4657,16 +4658,16 @@
     /* middle part - process nodes with cardinality of 0..n */
     if (c_must) {
         leaf->must = calloc(c_must, sizeof *leaf->must);
-        LY_CHECK_ERR_GOTO(!leaf->must, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!leaf->must, LOGMEM(ctx), error);
     }
     if (c_ftrs) {
         leaf->iffeature = calloc(c_ftrs, sizeof *leaf->iffeature);
-        LY_CHECK_ERR_GOTO(!leaf->iffeature, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!leaf->iffeature, LOGMEM(ctx), error);
     }
     if (c_ext) {
         /* some extensions may be already present from the substatements */
         reallocated = realloc(retval->ext, (c_ext + retval->ext_size) * sizeof *retval->ext);
-        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM(ctx), error);
         retval->ext = reallocated;
 
         /* init memory */
@@ -4704,14 +4705,14 @@
 
     /* check default value (if not defined, there still could be some restrictions
      * that need to be checked against a default value from a derived type) */
-    if (!(options & LYS_PARSE_OPT_INGRP) && !(module->ctx->models.flags & LY_CTX_TRUSTED) &&
+    if (!(options & LYS_PARSE_OPT_INGRP) && !(ctx->models.flags & LY_CTX_TRUSTED) &&
             (unres_schema_add_node(module, unres, &leaf->type, UNRES_TYPE_DFLT,
                                    (struct lys_node *)(&leaf->dflt)) == -1)) {
         goto error;
     }
 
     /* check XPath dependencies */
-    if (!(module->ctx->models.flags & LY_CTX_TRUSTED) && (leaf->when || leaf->must)) {
+    if (!(ctx->models.flags & LY_CTX_TRUSTED) && (leaf->when || leaf->must)) {
         if (options & LYS_PARSE_OPT_INGRP) {
             if (lyxp_node_check_syntax(retval)) {
                 goto error;
@@ -4726,9 +4727,7 @@
     return retval;
 
 error:
-
     lys_node_free(retval, NULL, 0);
-
     return NULL;
 }
 
@@ -4737,6 +4736,7 @@
 read_yin_leaflist(struct lys_module *module, struct lys_node *parent, struct lyxml_elem *yin, int options,
                   struct unres_schema *unres)
 {
+    struct ly_ctx *ctx = module->ctx;
     struct lys_node *retval;
     struct lys_node_leaflist *llist;
     struct lyxml_elem *sub, *next;
@@ -4749,7 +4749,7 @@
     void *reallocated;
 
     llist = calloc(1, sizeof *llist);
-    LY_CHECK_ERR_RETURN(!llist, LOGMEM, NULL);
+    LY_CHECK_ERR_RETURN(!llist, LOGMEM(ctx), NULL);
 
     llist->nodetype = LYS_LEAFLIST;
     llist->prev = (struct lys_node *)llist;
@@ -4772,12 +4772,12 @@
     LY_TREE_FOR_SAFE(yin->child, next, sub) {
         if (strcmp(sub->ns->value, LY_NSYIN)) {
             /* extension */
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ext, retval->ext_size, "extensions", "leaf-list", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ext, retval->ext_size, "extensions", "leaf-list", error);
             c_ext++;
             continue;
         } else if (!strcmp(sub->name, "type")) {
             if (has_type) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
                 goto error;
             }
             /* HACK for unres */
@@ -4788,18 +4788,18 @@
             has_type = 1;
         } else if (!strcmp(sub->name, "units")) {
             if (llist->units) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
                 goto error;
             }
-            GETVAL(value, sub, "name");
-            llist->units = lydict_insert(module->ctx, value, strlen(value));
+            GETVAL(ctx, value, sub, "name");
+            llist->units = lydict_insert(ctx, value, strlen(value));
 
             if (lyp_yin_parse_subnode_ext(module, retval, LYEXT_PAR_NODE, sub, LYEXT_SUBSTMT_UNITS, 0, unres)) {
                 goto error;
             }
         } else if (!strcmp(sub->name, "ordered-by")) {
             if (f_ordr) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
                 goto error;
             }
             /* just checking the flags in llist is not sufficient, we would
@@ -4811,15 +4811,15 @@
                 /* RFC 6020, 7.7.5 - ignore ordering when the list represents
                  * state data
                  */
-                lyxml_free(module->ctx, sub);
+                lyxml_free(ctx, sub);
                 continue;
             }
 
-            GETVAL(value, sub, "value");
+            GETVAL(ctx, value, sub, "value");
             if (!strcmp(value, "user")) {
                 llist->flags |= LYS_USERORDERED;
             } else if (strcmp(value, "system")) {
-                LOGVAL(LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
+                LOGVAL(ctx, LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
                 goto error;
             } /* else system is the default value, so we can ignore it */
 
@@ -4827,11 +4827,11 @@
                 goto error;
             }
         } else if (!strcmp(sub->name, "must")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_must, llist->must_size, "musts", "leaf-list", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_must, llist->must_size, "musts", "leaf-list", error);
             c_must++;
             continue;
         } else if (!strcmp(sub->name, "if-feature")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ftrs, retval->iffeature_size, "if-features", "leaf-list", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ftrs, retval->iffeature_size, "if-features", "leaf-list", error);
             c_ftrs++;
             continue;
         } else if ((module->version >= 2) && !strcmp(sub->name, "default")) {
@@ -4840,18 +4840,18 @@
                 goto error;
             }
 
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_dflt, llist->dflt_size, "defaults", "leaf-list", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_dflt, llist->dflt_size, "defaults", "leaf-list", error);
             c_dflt++;
             continue;
 
         } else if (!strcmp(sub->name, "min-elements")) {
             if (f_min) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
                 goto error;
             }
             f_min = 1;
 
-            GETVAL(value, sub, "value");
+            GETVAL(ctx, value, sub, "value");
             while (isspace(value[0])) {
                 value++;
             }
@@ -4861,13 +4861,13 @@
             endptr = NULL;
             val = strtoul(value, &endptr, 10);
             if (*endptr || value[0] == '-' || errno || val > UINT32_MAX) {
-                LOGVAL(LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
+                LOGVAL(ctx, LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
                 goto error;
             }
             llist->min = (uint32_t) val;
             if (llist->max && (llist->min > llist->max)) {
-                LOGVAL(LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
-                LOGVAL(LYE_SPEC, LY_VLOG_PREV, NULL, "\"min-elements\" is bigger than \"max-elements\".");
+                LOGVAL(ctx, LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
+                LOGVAL(ctx, LYE_SPEC, LY_VLOG_PREV, NULL, "\"min-elements\" is bigger than \"max-elements\".");
                 goto error;
             }
 
@@ -4876,12 +4876,12 @@
             }
         } else if (!strcmp(sub->name, "max-elements")) {
             if (f_max) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
                 goto error;
             }
             f_max = 1;
 
-            GETVAL(value, sub, "value");
+            GETVAL(ctx, value, sub, "value");
             while (isspace(value[0])) {
                 value++;
             }
@@ -4894,13 +4894,13 @@
                 endptr = NULL;
                 val = strtoul(value, &endptr, 10);
                 if (*endptr || value[0] == '-' || errno || val == 0 || val > UINT32_MAX) {
-                    LOGVAL(LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
+                    LOGVAL(ctx, LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
                     goto error;
                 }
                 llist->max = (uint32_t) val;
                 if (llist->min > llist->max) {
-                    LOGVAL(LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
-                    LOGVAL(LYE_SPEC, LY_VLOG_PREV, NULL, "\"max-elements\" is smaller than \"min-elements\".");
+                    LOGVAL(ctx, LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
+                    LOGVAL(ctx, LYE_SPEC, LY_VLOG_PREV, NULL, "\"max-elements\" is smaller than \"min-elements\".");
                     goto error;
                 }
             }
@@ -4910,7 +4910,7 @@
             }
         } else if (!strcmp(sub->name, "when")) {
             if (llist->when) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
                 goto error;
             }
 
@@ -4919,7 +4919,7 @@
                 goto error;
             }
         } else {
-            LOGVAL(LYE_INSTMT, LY_VLOG_LYS, retval, sub->name);
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_LYS, retval, sub->name);
             goto error;
         }
 
@@ -4928,27 +4928,27 @@
 
     /* check constraints */
     if (!has_type) {
-        LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_LYS, retval, "type", yin->name);
+        LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_LYS, retval, "type", yin->name);
         goto error;
     }
 
     /* middle part - process nodes with cardinality of 0..n */
     if (c_must) {
         llist->must = calloc(c_must, sizeof *llist->must);
-        LY_CHECK_ERR_GOTO(!llist->must, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!llist->must, LOGMEM(ctx), error);
     }
     if (c_ftrs) {
         llist->iffeature = calloc(c_ftrs, sizeof *llist->iffeature);
-        LY_CHECK_ERR_GOTO(!llist->iffeature, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!llist->iffeature, LOGMEM(ctx), error);
     }
     if (c_dflt) {
         llist->dflt = calloc(c_dflt, sizeof *llist->dflt);
-        LY_CHECK_ERR_GOTO(!llist->dflt, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!llist->dflt, LOGMEM(ctx), error);
     }
     if (c_ext) {
         /* some extensions may be already present from the substatements */
         reallocated = realloc(retval->ext, (c_ext + retval->ext_size) * sizeof *retval->ext);
-        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM(ctx), error);
         retval->ext = reallocated;
 
         /* init memory */
@@ -4976,20 +4976,20 @@
                 goto error;
             }
         } else if (!strcmp(sub->name, "default")) {
-            GETVAL(value, sub, "value");
+            GETVAL(ctx, value, sub, "value");
 
             /* check for duplicity in case of configuration data,
              * in case of status data duplicities are allowed */
             if (llist->flags & LYS_CONFIG_W) {
                 for (r = 0; r < llist->dflt_size; r++) {
                     if (ly_strequal(llist->dflt[r], value, 1)) {
-                        LOGVAL(LYE_INARG, LY_VLOG_LYS, retval, value, "default");
-                        LOGVAL(LYE_SPEC, LY_VLOG_PREV, NULL, "Duplicated default value \"%s\".", value);
+                        LOGVAL(ctx, LYE_INARG, LY_VLOG_LYS, retval, value, "default");
+                        LOGVAL(ctx, LYE_SPEC, LY_VLOG_PREV, NULL, "Duplicated default value \"%s\".", value);
                         goto error;
                     }
                 }
             }
-            llist->dflt[llist->dflt_size++] = lydict_insert(module->ctx, value, strlen(value));
+            llist->dflt[llist->dflt_size++] = lydict_insert(ctx, value, strlen(value));
         }
     }
 
@@ -5000,8 +5000,8 @@
     }
 
     if (llist->dflt_size && llist->min) {
-        LOGVAL(LYE_INCHILDSTMT, LY_VLOG_LYS, retval, "min-elements", "leaf-list");
-        LOGVAL(LYE_SPEC, LY_VLOG_PREV, NULL,
+        LOGVAL(ctx, LYE_INCHILDSTMT, LY_VLOG_LYS, retval, "min-elements", "leaf-list");
+        LOGVAL(ctx, LYE_SPEC, LY_VLOG_PREV, NULL,
                "The \"min-elements\" statement with non-zero value is forbidden on leaf-lists with the \"default\" statement.");
         goto error;
     }
@@ -5009,7 +5009,7 @@
     /* check default value (if not defined, there still could be some restrictions
      * that need to be checked against a default value from a derived type) */
     for (r = 0; r < llist->dflt_size; r++) {
-        if (!(options & LYS_PARSE_OPT_INGRP) && !(module->ctx->models.flags & LY_CTX_TRUSTED) &&
+        if (!(options & LYS_PARSE_OPT_INGRP) && !(ctx->models.flags & LY_CTX_TRUSTED) &&
                 (unres_schema_add_node(module, unres, &llist->type, UNRES_TYPE_DFLT,
                                        (struct lys_node *)(&llist->dflt[r])) == -1)) {
             goto error;
@@ -5017,7 +5017,7 @@
     }
 
     /* check XPath dependencies */
-    if (!(module->ctx->models.flags & LY_CTX_TRUSTED) && (llist->when || llist->must)) {
+    if (!(ctx->models.flags & LY_CTX_TRUSTED) && (llist->when || llist->must)) {
         if (options & LYS_PARSE_OPT_INGRP) {
             if (lyxp_node_check_syntax(retval)) {
                 goto error;
@@ -5032,9 +5032,7 @@
     return retval;
 
 error:
-
     lys_node_free(retval, NULL, 0);
-
     return NULL;
 }
 
@@ -5043,6 +5041,7 @@
 read_yin_list(struct lys_module *module, struct lys_node *parent, struct lyxml_elem *yin, int options,
               struct unres_schema *unres)
 {
+    struct ly_ctx *ctx = module->ctx;
     struct lys_node *retval, *node;
     struct lys_node_list *list;
     struct lyxml_elem *sub, *next, root, uniq;
@@ -5059,7 +5058,7 @@
     memset(&uniq, 0, sizeof uniq);
 
     list = calloc(1, sizeof *list);
-    LY_CHECK_ERR_RETURN(!list, LOGMEM, NULL);
+    LY_CHECK_ERR_RETURN(!list, LOGMEM(ctx), NULL);
 
     list->nodetype = LYS_LIST;
     list->prev = (struct lys_node *)list;
@@ -5083,7 +5082,7 @@
     LY_TREE_FOR_SAFE(yin->child, next, sub) {
         if (strcmp(sub->ns->value, LY_NSYIN)) {
             /* extension */
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ext, retval->ext_size, "extensions", "list", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ext, retval->ext_size, "extensions", "list", error);
             c_ext++;
             continue;
 
@@ -5099,20 +5098,20 @@
                 !strcmp(sub->name, "anydata") ||
                 !strcmp(sub->name, "action") ||
                 !strcmp(sub->name, "notification")) {
-            lyxml_unlink_elem(module->ctx, sub, 2);
-            lyxml_add_child(module->ctx, &root, sub);
+            lyxml_unlink_elem(ctx, sub, 2);
+            lyxml_add_child(ctx, &root, sub);
 
             /* array counters */
         } else if (!strcmp(sub->name, "key")) {
             /* check cardinality 0..1 */
             if (list->keys_size) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, list->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, list->name);
                 goto error;
             }
 
             /* count the number of keys */
-            GETVAL(value, sub, "value");
-            list->keys_str = lydict_insert(module->ctx, value, 0);
+            GETVAL(ctx, value, sub, "value");
+            list->keys_str = lydict_insert(ctx, value, 0);
             while ((value = strpbrk(value, " \t\n"))) {
                 list->keys_size++;
                 while (isspace(*value)) {
@@ -5121,31 +5120,31 @@
             }
             list->keys_size++;
             list->keys = calloc(list->keys_size, sizeof *list->keys);
-            LY_CHECK_ERR_GOTO(!list->keys, LOGMEM, error);
+            LY_CHECK_ERR_GOTO(!list->keys, LOGMEM(ctx), error);
 
             if (lyp_yin_parse_subnode_ext(module, retval, LYEXT_PAR_NODE, sub, LYEXT_SUBSTMT_KEY, 0, unres)) {
                 goto error;
             }
-            lyxml_free(module->ctx, sub);
+            lyxml_free(ctx, sub);
         } else if (!strcmp(sub->name, "unique")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_uniq, list->unique_size, "uniques", "list", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_uniq, list->unique_size, "uniques", "list", error);
             c_uniq++;
-            lyxml_unlink_elem(module->ctx, sub, 2);
-            lyxml_add_child(module->ctx, &uniq, sub);
+            lyxml_unlink_elem(ctx, sub, 2);
+            lyxml_add_child(ctx, &uniq, sub);
         } else if (!strcmp(sub->name, "typedef")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_tpdf, list->tpdf_size, "typedefs", "list", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_tpdf, list->tpdf_size, "typedefs", "list", error);
             c_tpdf++;
         } else if (!strcmp(sub->name, "must")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_must, list->must_size, "musts", "list", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_must, list->must_size, "musts", "list", error);
             c_must++;
         } else if (!strcmp(sub->name, "if-feature")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ftrs, retval->iffeature_size, "if-features", "list", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ftrs, retval->iffeature_size, "if-features", "list", error);
             c_ftrs++;
 
             /* optional stetments */
         } else if (!strcmp(sub->name, "ordered-by")) {
             if (f_ordr) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
                 goto error;
             }
             /* just checking the flags in llist is not sufficient, we would
@@ -5157,30 +5156,30 @@
                 /* RFC 6020, 7.7.5 - ignore ordering when the list represents
                  * state data
                  */
-                lyxml_free(module->ctx, sub);
+                lyxml_free(ctx, sub);
                 continue;
             }
 
-            GETVAL(value, sub, "value");
+            GETVAL(ctx, value, sub, "value");
             if (!strcmp(value, "user")) {
                 list->flags |= LYS_USERORDERED;
             } else if (strcmp(value, "system")) {
-                LOGVAL(LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
+                LOGVAL(ctx, LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
                 goto error;
             } /* else system is the default value, so we can ignore it */
 
             if (lyp_yin_parse_subnode_ext(module, retval, LYEXT_PAR_NODE, sub, LYEXT_SUBSTMT_ORDEREDBY, 0, unres)) {
                 goto error;
             }
-            lyxml_free(module->ctx, sub);
+            lyxml_free(ctx, sub);
         } else if (!strcmp(sub->name, "min-elements")) {
             if (f_min) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
                 goto error;
             }
             f_min = 1;
 
-            GETVAL(value, sub, "value");
+            GETVAL(ctx, value, sub, "value");
             while (isspace(value[0])) {
                 value++;
             }
@@ -5190,28 +5189,28 @@
             auxs = NULL;
             val = strtoul(value, &auxs, 10);
             if (*auxs || value[0] == '-' || errno || val > UINT32_MAX) {
-                LOGVAL(LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
+                LOGVAL(ctx, LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
                 goto error;
             }
             list->min = (uint32_t) val;
             if (list->max && (list->min > list->max)) {
-                LOGVAL(LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
-                LOGVAL(LYE_SPEC, LY_VLOG_PREV, NULL, "\"min-elements\" is bigger than \"max-elements\".");
-                lyxml_free(module->ctx, sub);
+                LOGVAL(ctx, LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
+                LOGVAL(ctx, LYE_SPEC, LY_VLOG_PREV, NULL, "\"min-elements\" is bigger than \"max-elements\".");
+                lyxml_free(ctx, sub);
                 goto error;
             }
             if (lyp_yin_parse_subnode_ext(module, retval, LYEXT_PAR_NODE, sub, LYEXT_SUBSTMT_MIN, 0, unres)) {
                 goto error;
             }
-            lyxml_free(module->ctx, sub);
+            lyxml_free(ctx, sub);
         } else if (!strcmp(sub->name, "max-elements")) {
             if (f_max) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
                 goto error;
             }
             f_max = 1;
 
-            GETVAL(value, sub, "value");
+            GETVAL(ctx, value, sub, "value");
             while (isspace(value[0])) {
                 value++;
             }
@@ -5224,34 +5223,34 @@
                 auxs = NULL;
                 val = strtoul(value, &auxs, 10);
                 if (*auxs || value[0] == '-' || errno || val == 0 || val > UINT32_MAX) {
-                    LOGVAL(LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
+                    LOGVAL(ctx, LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
                     goto error;
                 }
                 list->max = (uint32_t) val;
                 if (list->min > list->max) {
-                    LOGVAL(LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
-                    LOGVAL(LYE_SPEC, LY_VLOG_PREV, NULL, "\"max-elements\" is smaller than \"min-elements\".");
+                    LOGVAL(ctx, LYE_INARG, LY_VLOG_LYS, retval, value, sub->name);
+                    LOGVAL(ctx, LYE_SPEC, LY_VLOG_PREV, NULL, "\"max-elements\" is smaller than \"min-elements\".");
                     goto error;
                 }
             }
             if (lyp_yin_parse_subnode_ext(module, retval, LYEXT_PAR_NODE, sub, LYEXT_SUBSTMT_MAX, 0, unres)) {
                 goto error;
             }
-            lyxml_free(module->ctx, sub);
+            lyxml_free(ctx, sub);
         } else if (!strcmp(sub->name, "when")) {
             if (list->when) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
                 goto error;
             }
 
             list->when = read_yin_when(module, sub, unres);
             if (!list->when) {
-                lyxml_free(module->ctx, sub);
+                lyxml_free(ctx, sub);
                 goto error;
             }
-            lyxml_free(module->ctx, sub);
+            lyxml_free(ctx, sub);
         } else {
-            LOGVAL(LYE_INSTMT, LY_VLOG_LYS, retval, sub->name);
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_LYS, retval, sub->name);
             goto error;
         }
     }
@@ -5260,27 +5259,27 @@
      * (but only if we are not in a grouping or augment, then the check is deferred) */
     for (node = retval; node && !(node->nodetype & (LYS_GROUPING | LYS_AUGMENT | LYS_EXT)); node = node->parent);
     if (!node && (list->flags & LYS_CONFIG_W) && !list->keys_str) {
-        LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_LYS, retval, "key", "list");
+        LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_LYS, retval, "key", "list");
         goto error;
     }
 
     /* middle part - process nodes with cardinality of 0..n except the data nodes */
     if (c_tpdf) {
         list->tpdf = calloc(c_tpdf, sizeof *list->tpdf);
-        LY_CHECK_ERR_GOTO(!list->tpdf, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!list->tpdf, LOGMEM(ctx), error);
     }
     if (c_must) {
         list->must = calloc(c_must, sizeof *list->must);
-        LY_CHECK_ERR_GOTO(!list->must, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!list->must, LOGMEM(ctx), error);
     }
     if (c_ftrs) {
         list->iffeature = calloc(c_ftrs, sizeof *list->iffeature);
-        LY_CHECK_ERR_GOTO(!list->iffeature, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!list->iffeature, LOGMEM(ctx), error);
     }
     if (c_ext) {
         /* some extensions may be already present from the substatements */
         reallocated = realloc(retval->ext, (c_ext + retval->ext_size) * sizeof *retval->ext);
-        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM(ctx), error);
         retval->ext = reallocated;
 
         /* init memory */
@@ -5341,14 +5340,14 @@
         } else if (!strcmp(sub->name, "notification")) {
             node = read_yin_notif(module, retval, sub, options, unres);
         } else {
-            LOGINT;
+            LOGINT(ctx);
             goto error;
         }
         if (!node) {
             goto error;
         }
 
-        lyxml_free(module->ctx, sub);
+        lyxml_free(ctx, sub);
     }
 
     if (list->keys_str) {
@@ -5362,7 +5361,7 @@
     /* process unique statements */
     if (c_uniq) {
         list->unique = calloc(c_uniq, sizeof *list->unique);
-        LY_CHECK_ERR_GOTO(!list->unique, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!list->unique, LOGMEM(ctx), error);
 
         LY_TREE_FOR_SAFE(uniq.child, next, sub) {
             r = fill_yin_unique(module, retval, sub, &list->unique[list->unique_size], unres);
@@ -5375,12 +5374,12 @@
                                      LYEXT_SUBSTMT_UNIQUE, list->unique_size - 1, unres)) {
                 goto error;
             }
-            lyxml_free(module->ctx, sub);
+            lyxml_free(ctx, sub);
         }
     }
 
     /* check XPath dependencies */
-    if (!(module->ctx->models.flags & LY_CTX_TRUSTED) && (list->when || list->must)) {
+    if (!(ctx->models.flags & LY_CTX_TRUSTED) && (list->when || list->must)) {
         if (options & LYS_PARSE_OPT_INGRP) {
             if (lyxp_node_check_syntax(retval)) {
                 goto error;
@@ -5398,10 +5397,10 @@
 
     lys_node_free(retval, NULL, 0);
     while (root.child) {
-        lyxml_free(module->ctx, root.child);
+        lyxml_free(ctx, root.child);
     }
     while (uniq.child) {
-        lyxml_free(module->ctx, uniq.child);
+        lyxml_free(ctx, uniq.child);
     }
 
     return NULL;
@@ -5412,6 +5411,7 @@
 read_yin_container(struct lys_module *module, struct lys_node *parent, struct lyxml_elem *yin, int options,
                    struct unres_schema *unres)
 {
+    struct ly_ctx *ctx = module->ctx;
     struct lyxml_elem *sub, *next, root;
     struct lys_node *node = NULL;
     struct lys_node *retval;
@@ -5425,7 +5425,7 @@
     memset(&root, 0, sizeof root);
 
     cont = calloc(1, sizeof *cont);
-    LY_CHECK_ERR_RETURN(!cont, LOGMEM, NULL);
+    LY_CHECK_ERR_RETURN(!cont, LOGMEM(ctx), NULL);
 
     cont->nodetype = LYS_CONTAINER;
     cont->prev = (struct lys_node *)cont;
@@ -5449,32 +5449,32 @@
     LY_TREE_FOR_SAFE(yin->child, next, sub) {
         if (strcmp(sub->ns->value, LY_NSYIN)) {
             /* extension */
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ext, retval->ext_size, "extensions", "container", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ext, retval->ext_size, "extensions", "container", error);
             c_ext++;
         } else if (!strcmp(sub->name, "presence")) {
             if (cont->presence) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
                 goto error;
             }
-            GETVAL(value, sub, "value");
-            cont->presence = lydict_insert(module->ctx, value, strlen(value));
+            GETVAL(ctx, value, sub, "value");
+            cont->presence = lydict_insert(ctx, value, strlen(value));
 
             if (lyp_yin_parse_subnode_ext(module, retval, LYEXT_PAR_NODE, sub, LYEXT_SUBSTMT_PRESENCE, 0, unres)) {
                 goto error;
             }
-            lyxml_free(module->ctx, sub);
+            lyxml_free(ctx, sub);
         } else if (!strcmp(sub->name, "when")) {
             if (cont->when) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
                 goto error;
             }
 
             cont->when = read_yin_when(module, sub, unres);
             if (!cont->when) {
-                lyxml_free(module->ctx, sub);
+                lyxml_free(ctx, sub);
                 goto error;
             }
-            lyxml_free(module->ctx, sub);
+            lyxml_free(ctx, sub);
 
             /* data statements */
         } else if (!strcmp(sub->name, "container") ||
@@ -5488,21 +5488,21 @@
                 !strcmp(sub->name, "anydata") ||
                 !strcmp(sub->name, "action") ||
                 !strcmp(sub->name, "notification")) {
-            lyxml_unlink_elem(module->ctx, sub, 2);
-            lyxml_add_child(module->ctx, &root, sub);
+            lyxml_unlink_elem(ctx, sub, 2);
+            lyxml_add_child(ctx, &root, sub);
 
             /* array counters */
         } else if (!strcmp(sub->name, "typedef")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_tpdf, cont->tpdf_size, "typedefs", "container", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_tpdf, cont->tpdf_size, "typedefs", "container", error);
             c_tpdf++;
         } else if (!strcmp(sub->name, "must")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_must, cont->must_size, "musts", "container", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_must, cont->must_size, "musts", "container", error);
             c_must++;
         } else if (!strcmp(sub->name, "if-feature")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ftrs, retval->iffeature_size, "if-features", "container", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ftrs, retval->iffeature_size, "if-features", "container", error);
             c_ftrs++;
         } else {
-            LOGVAL(LYE_INSTMT, LY_VLOG_LYS, retval, sub->name);
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_LYS, retval, sub->name);
             goto error;
         }
     }
@@ -5510,20 +5510,20 @@
     /* middle part - process nodes with cardinality of 0..n except the data nodes */
     if (c_tpdf) {
         cont->tpdf = calloc(c_tpdf, sizeof *cont->tpdf);
-        LY_CHECK_ERR_GOTO(!cont->tpdf, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!cont->tpdf, LOGMEM(ctx), error);
     }
     if (c_must) {
         cont->must = calloc(c_must, sizeof *cont->must);
-        LY_CHECK_ERR_GOTO(!cont->must, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!cont->must, LOGMEM(ctx), error);
     }
     if (c_ftrs) {
         cont->iffeature = calloc(c_ftrs, sizeof *cont->iffeature);
-        LY_CHECK_ERR_GOTO(!cont->iffeature, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!cont->iffeature, LOGMEM(ctx), error);
     }
     if (c_ext) {
         /* some extensions may be already present from the substatements */
         reallocated = realloc(retval->ext, (c_ext + retval->ext_size) * sizeof *retval->ext);
-        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM(ctx), error);
         retval->ext = reallocated;
 
         /* init memory */
@@ -5588,11 +5588,11 @@
             goto error;
         }
 
-        lyxml_free(module->ctx, sub);
+        lyxml_free(ctx, sub);
     }
 
     /* check XPath dependencies */
-    if (!(module->ctx->models.flags & LY_CTX_TRUSTED) && (cont->when || cont->must)) {
+    if (!(ctx->models.flags & LY_CTX_TRUSTED) && (cont->when || cont->must)) {
         if (options & LYS_PARSE_OPT_INGRP) {
             if (lyxp_node_check_syntax(retval)) {
                 goto error;
@@ -5607,12 +5607,10 @@
     return retval;
 
 error:
-
     lys_node_free(retval, NULL, 0);
     while (root.child) {
-        lyxml_free(module->ctx, root.child);
+        lyxml_free(ctx, root.child);
     }
-
     return NULL;
 }
 
@@ -5621,6 +5619,7 @@
 read_yin_grouping(struct lys_module *module, struct lys_node *parent, struct lyxml_elem *yin, int options,
                   struct unres_schema *unres)
 {
+    struct ly_ctx *ctx = module->ctx;
     struct lyxml_elem *sub, *next, root;
     struct lys_node *node = NULL;
     struct lys_node *retval;
@@ -5633,7 +5632,7 @@
     memset(&root, 0, sizeof root);
 
     grp = calloc(1, sizeof *grp);
-    LY_CHECK_ERR_RETURN(!grp, LOGMEM, NULL);
+    LY_CHECK_ERR_RETURN(!grp, LOGMEM(ctx), NULL);
 
     grp->nodetype = LYS_GROUPING;
     grp->prev = (struct lys_node *)grp;
@@ -5653,7 +5652,7 @@
     LY_TREE_FOR_SAFE(yin->child, next, sub) {
         if (strcmp(sub->ns->value, LY_NSYIN)) {
             /* extension */
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ext, retval->ext_size, "extensions", "grouping", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ext, retval->ext_size, "extensions", "grouping", error);
             c_ext++;
 
         /* data statements */
@@ -5668,15 +5667,15 @@
                 !strcmp(sub->name, "anydata") ||
                 !strcmp(sub->name, "action") ||
                 !strcmp(sub->name, "notification")) {
-            lyxml_unlink_elem(module->ctx, sub, 2);
-            lyxml_add_child(module->ctx, &root, sub);
+            lyxml_unlink_elem(ctx, sub, 2);
+            lyxml_add_child(ctx, &root, sub);
 
             /* array counters */
         } else if (!strcmp(sub->name, "typedef")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_tpdf, grp->tpdf_size, "typedefs", "grouping", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_tpdf, grp->tpdf_size, "typedefs", "grouping", error);
             c_tpdf++;
         } else {
-            LOGVAL(LYE_INSTMT, LY_VLOG_LYS, retval, sub->name);
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_LYS, retval, sub->name);
             goto error;
         }
     }
@@ -5684,12 +5683,12 @@
     /* middle part - process nodes with cardinality of 0..n except the data nodes */
     if (c_tpdf) {
         grp->tpdf = calloc(c_tpdf, sizeof *grp->tpdf);
-        LY_CHECK_ERR_GOTO(!grp->tpdf, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!grp->tpdf, LOGMEM(ctx), error);
     }
     if (c_ext) {
         /* some extensions may be already present from the substatements */
         reallocated = realloc(retval->ext, (c_ext + retval->ext_size) * sizeof *retval->ext);
-        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM(ctx), error);
         retval->ext = reallocated;
 
         /* init memory */
@@ -5715,7 +5714,7 @@
 
     /* last part - process data nodes */
     if (!root.child) {
-        LOGWRN("Grouping \"%s\" without children.", retval->name);
+        LOGWRN(ctx, "Grouping \"%s\" without children.", retval->name);
     }
     options |= LYS_PARSE_OPT_INGRP;
     LY_TREE_FOR_SAFE(root.child, next, sub) {
@@ -5746,18 +5745,16 @@
             goto error;
         }
 
-        lyxml_free(module->ctx, sub);
+        lyxml_free(ctx, sub);
     }
 
     return retval;
 
 error:
-
     lys_node_free(retval, NULL, 0);
     while (root.child) {
-        lyxml_free(module->ctx, root.child);
+        lyxml_free(ctx, root.child);
     }
-
     return NULL;
 }
 
@@ -5766,6 +5763,7 @@
 read_yin_input_output(struct lys_module *module, struct lys_node *parent, struct lyxml_elem *yin,
                       int options, struct unres_schema *unres)
 {
+    struct ly_ctx *ctx = module->ctx;
     struct lyxml_elem *sub, *next, root;
     struct lys_node *node = NULL;
     struct lys_node *retval = NULL;
@@ -5777,17 +5775,17 @@
     memset(&root, 0, sizeof root);
 
     inout = calloc(1, sizeof *inout);
-    LY_CHECK_ERR_RETURN(!inout, LOGMEM, NULL);
+    LY_CHECK_ERR_RETURN(!inout, LOGMEM(ctx), NULL);
     inout->prev = (struct lys_node *)inout;
 
     if (!strcmp(yin->name, "input")) {
         inout->nodetype = LYS_INPUT;
-        inout->name = lydict_insert(module->ctx, "input", 0);
+        inout->name = lydict_insert(ctx, "input", 0);
     } else if (!strcmp(yin->name, "output")) {
         inout->nodetype = LYS_OUTPUT;
-        inout->name = lydict_insert(module->ctx, "output", 0);
+        inout->name = lydict_insert(ctx, "output", 0);
     } else {
-        LOGINT;
+        LOGINT(ctx);
         free(inout);
         goto error;
     }
@@ -5806,10 +5804,10 @@
     LY_TREE_FOR_SAFE(yin->child, next, sub) {
         if (!sub->ns) {
             /* garbage */
-            lyxml_free(module->ctx, sub);
+            lyxml_free(ctx, sub);
         } else if (strcmp(sub->ns->value, LY_NSYIN)) {
             /* extension */
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ext, retval->ext_size, "extensions",
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ext, retval->ext_size, "extensions",
                                           inout->nodetype == LYS_INPUT ? "input" : "output", error);
             c_ext++;
         } else if (!strcmp(sub->name, "container") ||
@@ -5821,22 +5819,22 @@
                 !strcmp(sub->name, "grouping") ||
                 !strcmp(sub->name, "anyxml") ||
                 !strcmp(sub->name, "anydata")) {
-            lyxml_unlink_elem(module->ctx, sub, 2);
-            lyxml_add_child(module->ctx, &root, sub);
+            lyxml_unlink_elem(ctx, sub, 2);
+            lyxml_add_child(ctx, &root, sub);
 
             /* array counters */
         } else if (!strcmp(sub->name, "typedef")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_tpdf, inout->tpdf_size, "typedefs",
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_tpdf, inout->tpdf_size, "typedefs",
                                           inout->nodetype == LYS_INPUT ? "input" : "output", error);
             c_tpdf++;
 
         } else if ((module->version >= 2) && !strcmp(sub->name, "must")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_must, inout->must_size, "musts",
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_must, inout->must_size, "musts",
                                           inout->nodetype == LYS_INPUT ? "input" : "output", error);
             c_must++;
 
         } else {
-            LOGVAL(LYE_INSTMT, LY_VLOG_LYS, retval, sub->name);
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_LYS, retval, sub->name);
             goto error;
         }
     }
@@ -5844,15 +5842,15 @@
     /* middle part - process nodes with cardinality of 0..n except the data nodes */
     if (c_tpdf) {
         inout->tpdf = calloc(c_tpdf, sizeof *inout->tpdf);
-        LY_CHECK_ERR_GOTO(!inout->tpdf, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!inout->tpdf, LOGMEM(ctx), error);
     }
     if (c_must) {
         inout->must = calloc(c_must, sizeof *inout->must);
-        LY_CHECK_ERR_GOTO(!inout->must, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!inout->must, LOGMEM(ctx), error);
     }
     if (c_ext) {
         inout->ext = calloc(c_ext, sizeof *inout->ext);
-        LY_CHECK_ERR_GOTO(!inout->ext, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!inout->ext, LOGMEM(ctx), error);
     }
 
     LY_TREE_FOR_SAFE(yin->child, next, sub) {
@@ -5904,11 +5902,11 @@
             goto error;
         }
 
-        lyxml_free(module->ctx, sub);
+        lyxml_free(ctx, sub);
     }
 
     /* check XPath dependencies */
-    if (!(module->ctx->models.flags & LY_CTX_TRUSTED) && inout->must) {
+    if (!(ctx->models.flags & LY_CTX_TRUSTED) && inout->must) {
         if (options & LYS_PARSE_OPT_INGRP) {
             if (lyxp_node_check_syntax(retval)) {
                 goto error;
@@ -5923,12 +5921,10 @@
     return retval;
 
 error:
-
     lys_node_free(retval, NULL, 0);
     while (root.child) {
-        lyxml_free(module->ctx, root.child);
+        lyxml_free(ctx, root.child);
     }
-
     return NULL;
 }
 
@@ -5937,6 +5933,7 @@
 read_yin_notif(struct lys_module *module, struct lys_node *parent, struct lyxml_elem *yin,
                int options, struct unres_schema *unres)
 {
+    struct ly_ctx *ctx = module->ctx;
     struct lyxml_elem *sub, *next, root;
     struct lys_node *node = NULL;
     struct lys_node *retval;
@@ -5946,14 +5943,14 @@
     void *reallocated;
 
     if (parent && (module->version < 2)) {
-        LOGVAL(LYE_INSTMT, LY_VLOG_LYS, parent, "notification");
+        LOGVAL(ctx, LYE_INSTMT, LY_VLOG_LYS, parent, "notification");
         return NULL;
     }
 
     memset(&root, 0, sizeof root);
 
     notif = calloc(1, sizeof *notif);
-    LY_CHECK_ERR_RETURN(!notif, LOGMEM, NULL);
+    LY_CHECK_ERR_RETURN(!notif, LOGMEM(ctx), NULL);
 
     notif->nodetype = LYS_NOTIF;
     notif->prev = (struct lys_node *)notif;
@@ -5974,7 +5971,7 @@
     LY_TREE_FOR_SAFE(yin->child, next, sub) {
         if (strcmp(sub->ns->value, LY_NSYIN)) {
             /* extension */
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ext, retval->ext_size, "extensions", "notification", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ext, retval->ext_size, "extensions", "notification", error);
             c_ext++;
             continue;
 
@@ -5988,21 +5985,21 @@
                 !strcmp(sub->name, "grouping") ||
                 !strcmp(sub->name, "anyxml") ||
                 !strcmp(sub->name, "anydata")) {
-            lyxml_unlink_elem(module->ctx, sub, 2);
-            lyxml_add_child(module->ctx, &root, sub);
+            lyxml_unlink_elem(ctx, sub, 2);
+            lyxml_add_child(ctx, &root, sub);
 
             /* array counters */
         } else if (!strcmp(sub->name, "typedef")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_tpdf, notif->tpdf_size, "typedefs", "notification", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_tpdf, notif->tpdf_size, "typedefs", "notification", error);
             c_tpdf++;
         } else if (!strcmp(sub->name, "if-feature")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ftrs, retval->iffeature_size, "if-features", "notification", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ftrs, retval->iffeature_size, "if-features", "notification", error);
             c_ftrs++;
         } else if ((module->version >= 2) && !strcmp(sub->name, "must")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_must, notif->must_size, "musts", "notification", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_must, notif->must_size, "musts", "notification", error);
             c_must++;
         } else {
-            LOGVAL(LYE_INSTMT, LY_VLOG_LYS, retval, sub->name);
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_LYS, retval, sub->name);
             goto error;
         }
     }
@@ -6010,20 +6007,20 @@
     /* middle part - process nodes with cardinality of 0..n except the data nodes */
     if (c_tpdf) {
         notif->tpdf = calloc(c_tpdf, sizeof *notif->tpdf);
-        LY_CHECK_ERR_GOTO(!notif->tpdf, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!notif->tpdf, LOGMEM(ctx), error);
     }
     if (c_ftrs) {
         notif->iffeature = calloc(c_ftrs, sizeof *notif->iffeature);
-        LY_CHECK_ERR_GOTO(!notif->iffeature, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!notif->iffeature, LOGMEM(ctx), error);
     }
     if (c_must) {
         notif->must = calloc(c_must, sizeof *notif->must);
-        LY_CHECK_ERR_GOTO(!notif->must, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!notif->must, LOGMEM(ctx), error);
     }
     if (c_ext) {
         /* some extensions may be already present from the substatements */
         reallocated = realloc(retval->ext, (c_ext + retval->ext_size) * sizeof *retval->ext);
-        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM(ctx), error);
         retval->ext = reallocated;
 
         /* init memory */
@@ -6085,11 +6082,11 @@
             goto error;
         }
 
-        lyxml_free(module->ctx, sub);
+        lyxml_free(ctx, sub);
     }
 
     /* check XPath dependencies */
-    if (!(module->ctx->models.flags & LY_CTX_TRUSTED) && notif->must) {
+    if (!(ctx->models.flags & LY_CTX_TRUSTED) && notif->must) {
         if (options & LYS_PARSE_OPT_INGRP) {
             if (lyxp_node_check_syntax(retval)) {
                 goto error;
@@ -6104,12 +6101,10 @@
     return retval;
 
 error:
-
     lys_node_free(retval, NULL, 0);
     while (root.child) {
-        lyxml_free(module->ctx, root.child);
+        lyxml_free(ctx, root.child);
     }
-
     return NULL;
 }
 
@@ -6118,6 +6113,7 @@
 read_yin_rpc_action(struct lys_module *module, struct lys_node *parent, struct lyxml_elem *yin,
                     int options, struct unres_schema *unres)
 {
+    struct ly_ctx *ctx = module->ctx;
     struct lyxml_elem *sub, *next, root;
     struct lys_node *node = NULL;
     struct lys_node *retval;
@@ -6128,13 +6124,13 @@
 
     if (!strcmp(yin->name, "action")) {
         if (module->version < 2) {
-            LOGVAL(LYE_INSTMT, LY_VLOG_LYS, parent, "action");
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_LYS, parent, "action");
             return NULL;
         }
         for (node = parent; node; node = lys_parent(node)) {
             if ((node->nodetype & (LYS_RPC | LYS_ACTION | LYS_NOTIF))
                     || ((node->nodetype == LYS_LIST) && !((struct lys_node_list *)node)->keys_size)) {
-                LOGVAL(LYE_INPAR, LY_VLOG_LYS, parent, strnodetype(node->nodetype), "action");
+                LOGVAL(ctx, LYE_INPAR, LY_VLOG_LYS, parent, strnodetype(node->nodetype), "action");
                 return NULL;
             }
         }
@@ -6144,7 +6140,7 @@
     memset(&root, 0, sizeof root);
 
     rpc = calloc(1, sizeof *rpc);
-    LY_CHECK_ERR_RETURN(!rpc, LOGMEM, NULL);
+    LY_CHECK_ERR_RETURN(!rpc, LOGMEM(ctx), NULL);
 
     rpc->nodetype = (!strcmp(yin->name, "rpc") ? LYS_RPC : LYS_ACTION);
     rpc->prev = (struct lys_node *)rpc;
@@ -6165,43 +6161,43 @@
     LY_TREE_FOR_SAFE(yin->child, next, sub) {
         if (strcmp(sub->ns->value, LY_NSYIN)) {
             /* extension */
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ext, retval->ext_size, "extensions",
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ext, retval->ext_size, "extensions",
                                           rpc->nodetype == LYS_RPC ? "rpc" : "action", error);
             c_ext++;
             continue;
         } else if (!strcmp(sub->name, "input")) {
             if (c_input) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
                 goto error;
             }
             c_input++;
-            lyxml_unlink_elem(module->ctx, sub, 2);
-            lyxml_add_child(module->ctx, &root, sub);
+            lyxml_unlink_elem(ctx, sub, 2);
+            lyxml_add_child(ctx, &root, sub);
         } else if (!strcmp(sub->name, "output")) {
             if (c_output) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
                 goto error;
             }
             c_output++;
-            lyxml_unlink_elem(module->ctx, sub, 2);
-            lyxml_add_child(module->ctx, &root, sub);
+            lyxml_unlink_elem(ctx, sub, 2);
+            lyxml_add_child(ctx, &root, sub);
 
             /* data statements */
         } else if (!strcmp(sub->name, "grouping")) {
-            lyxml_unlink_elem(module->ctx, sub, 2);
-            lyxml_add_child(module->ctx, &root, sub);
+            lyxml_unlink_elem(ctx, sub, 2);
+            lyxml_add_child(ctx, &root, sub);
 
             /* array counters */
         } else if (!strcmp(sub->name, "typedef")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_tpdf, rpc->tpdf_size, "typedefs",
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_tpdf, rpc->tpdf_size, "typedefs",
                                           rpc->nodetype == LYS_RPC ? "rpc" : "action", error);
             c_tpdf++;
         } else if (!strcmp(sub->name, "if-feature")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ftrs, retval->iffeature_size, "if-features",
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ftrs, retval->iffeature_size, "if-features",
                                           rpc->nodetype == LYS_RPC ? "rpc" : "action", error);
             c_ftrs++;
         } else {
-            LOGVAL(LYE_INSTMT, LY_VLOG_LYS, retval, sub->name);
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_LYS, retval, sub->name);
             goto error;
         }
     }
@@ -6209,16 +6205,16 @@
     /* middle part - process nodes with cardinality of 0..n except the data nodes */
     if (c_tpdf) {
         rpc->tpdf = calloc(c_tpdf, sizeof *rpc->tpdf);
-        LY_CHECK_ERR_GOTO(!rpc->tpdf, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!rpc->tpdf, LOGMEM(ctx), error);
     }
     if (c_ftrs) {
         rpc->iffeature = calloc(c_ftrs, sizeof *rpc->iffeature);
-        LY_CHECK_ERR_GOTO(!rpc->iffeature, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!rpc->iffeature, LOGMEM(ctx), error);
     }
     if (c_ext) {
         /* some extensions may be already present from the substatements */
         reallocated = realloc(retval->ext, (c_ext + retval->ext_size) * sizeof *retval->ext);
-        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM(ctx), error);
         retval->ext = reallocated;
 
         /* init memory */
@@ -6259,18 +6255,16 @@
             goto error;
         }
 
-        lyxml_free(module->ctx, sub);
+        lyxml_free(ctx, sub);
     }
 
     return retval;
 
 error:
-
     lys_node_free(retval, NULL, 0);
     while (root.child) {
-        lyxml_free(module->ctx, root.child);
+        lyxml_free(ctx, root.child);
     }
-
     return NULL;
 }
 
@@ -6284,6 +6278,7 @@
 read_yin_uses(struct lys_module *module, struct lys_node *parent, struct lyxml_elem *yin,
               int options, struct unres_schema *unres)
 {
+    struct ly_ctx *ctx = module->ctx;
     struct lyxml_elem *sub, *next;
     struct lys_node *retval;
     struct lys_node_uses *uses;
@@ -6293,14 +6288,14 @@
     void *reallocated;
 
     uses = calloc(1, sizeof *uses);
-    LY_CHECK_ERR_RETURN(!uses, LOGMEM, NULL);
+    LY_CHECK_ERR_RETURN(!uses, LOGMEM(ctx), NULL);
 
     uses->nodetype = LYS_USES;
     uses->prev = (struct lys_node *)uses;
     retval = (struct lys_node *)uses;
 
-    GETVAL(value, yin, "name");
-    uses->name = lydict_insert(module->ctx, value, 0);
+    GETVAL(ctx, value, yin, "name");
+    uses->name = lydict_insert(ctx, value, 0);
 
     if (read_yin_common(module, parent, retval, LYEXT_PAR_NODE, yin, OPT_MODULE, unres)) {
         goto error;
@@ -6317,32 +6312,32 @@
     LY_TREE_FOR_SAFE(yin->child, next, sub) {
         if (strcmp(sub->ns->value, LY_NSYIN)) {
             /* extension */
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ext, retval->ext_size, "extensions", "uses", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ext, retval->ext_size, "extensions", "uses", error);
             c_ext++;
             continue;
         } else if (!strcmp(sub->name, "refine")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ref, uses->refine_size, "refines", "uses", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ref, uses->refine_size, "refines", "uses", error);
             c_ref++;
         } else if (!strcmp(sub->name, "augment")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_aug, uses->augment_size, "augments", "uses", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_aug, uses->augment_size, "augments", "uses", error);
             c_aug++;
         } else if (!strcmp(sub->name, "if-feature")) {
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ftrs, retval->iffeature_size, "if-features", "uses", error);
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ftrs, retval->iffeature_size, "if-features", "uses", error);
             c_ftrs++;
         } else if (!strcmp(sub->name, "when")) {
             if (uses->when) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_LYS, retval, sub->name, yin->name);
                 goto error;
             }
 
             uses->when = read_yin_when(module, sub, unres);
             if (!uses->when) {
-                lyxml_free(module->ctx, sub);
+                lyxml_free(ctx, sub);
                 goto error;
             }
-            lyxml_free(module->ctx, sub);
+            lyxml_free(ctx, sub);
         } else {
-            LOGVAL(LYE_INSTMT, LY_VLOG_LYS, retval, sub->name);
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_LYS, retval, sub->name);
             goto error;
         }
     }
@@ -6350,20 +6345,20 @@
     /* process properties with cardinality 0..n */
     if (c_ref) {
         uses->refine = calloc(c_ref, sizeof *uses->refine);
-        LY_CHECK_ERR_GOTO(!uses->refine, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!uses->refine, LOGMEM(ctx), error);
     }
     if (c_aug) {
         uses->augment = calloc(c_aug, sizeof *uses->augment);
-        LY_CHECK_ERR_GOTO(!uses->augment, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!uses->augment, LOGMEM(ctx), error);
     }
     if (c_ftrs) {
         uses->iffeature = calloc(c_ftrs, sizeof *uses->iffeature);
-        LY_CHECK_ERR_GOTO(!uses->iffeature, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!uses->iffeature, LOGMEM(ctx), error);
     }
     if (c_ext) {
         /* some extensions may be already present from the substatements */
         reallocated = realloc(retval->ext, (c_ext + retval->ext_size) * sizeof *retval->ext);
-        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM(ctx), error);
         retval->ext = reallocated;
 
         /* init memory */
@@ -6404,7 +6399,7 @@
     }
 
     /* check XPath dependencies */
-    if (!(module->ctx->models.flags & LY_CTX_TRUSTED) && uses->when) {
+    if (!(ctx->models.flags & LY_CTX_TRUSTED) && uses->when) {
         if (options & LYS_PARSE_OPT_INGRP) {
             if (lyxp_node_check_syntax(retval)) {
                 goto error;
@@ -6419,9 +6414,7 @@
     return retval;
 
 error:
-
     lys_node_free(retval, NULL, 0);
-
     return NULL;
 }
 
@@ -6477,24 +6470,24 @@
             continue;
         } else if (strcmp(child->ns->value, LY_NSYIN)) {
             /* possible extension instance */
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_extinst, trg->ext_size, "extension instances",
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_extinst, trg->ext_size, "extension instances",
                                           submodule ? "submodule" : "module", error);
-            lyxml_unlink_elem(module->ctx, child, 2);
-            lyxml_add_child(module->ctx, &exts, child);
+            lyxml_unlink_elem(ctx, child, 2);
+            lyxml_add_child(ctx, &exts, child);
             c_extinst++;
         } else if (!submodule && !strcmp(child->name, "namespace")) {
             if (substmt_group > 0) {
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
-                LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Statement \"%s\" cannot appear after \"%s\" statement.",
+                LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
+                LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Statement \"%s\" cannot appear after \"%s\" statement.",
                        child->name, substmt_prev);
                 goto error;
             }
 
             if (trg->ns) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
                 goto error;
             }
-            GETVAL(value, child, "uri");
+            GETVAL(ctx, value, child, "uri");
             trg->ns = lydict_insert(ctx, value, strlen(value));
 
             if (lyp_yin_parse_subnode_ext(trg, trg, LYEXT_PAR_MODULE, child, LYEXT_SUBSTMT_NAMESPACE, 0, unres)) {
@@ -6505,18 +6498,18 @@
             substmt_prev = "namespace";
         } else if (!submodule && !strcmp(child->name, "prefix")) {
             if (substmt_group > 0) {
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
-                LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Statement \"%s\" cannot appear after \"%s\" statement.",
+                LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
+                LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Statement \"%s\" cannot appear after \"%s\" statement.",
                        child->name, substmt_prev);
                 goto error;
             }
 
             if (trg->prefix) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
                 goto error;
             }
-            GETVAL(value, child, "value");
-            if (lyp_check_identifier(value, LY_IDENT_PREFIX, trg, NULL)) {
+            GETVAL(ctx, value, child, "value");
+            if (lyp_check_identifier(ctx, value, LY_IDENT_PREFIX, trg, NULL)) {
                 goto error;
             }
             trg->prefix = lydict_insert(ctx, value, strlen(value));
@@ -6529,19 +6522,19 @@
             substmt_prev = "prefix";
         } else if (submodule && !strcmp(child->name, "belongs-to")) {
             if (substmt_group > 0) {
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
-                LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Statement \"%s\" cannot appear after \"%s\" statement.",
+                LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
+                LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Statement \"%s\" cannot appear after \"%s\" statement.",
                        child->name, substmt_prev);
                 goto error;
             }
 
             if (trg->prefix) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
                 goto error;
             }
-            GETVAL(value, child, "module");
+            GETVAL(ctx, value, child, "module");
             if (!ly_strequal(value, submodule->belongsto->name, 1)) {
-                LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, child->name);
+                LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, child->name);
                 goto error;
             }
 
@@ -6551,21 +6544,21 @@
 
             /* get the prefix substatement, start with checks */
             if (!child->child) {
-                LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "prefix", child->name);
+                LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "prefix", child->name);
                 goto error;
             } else if (strcmp(child->child->name, "prefix")) {
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->child->name);
+                LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->child->name);
                 goto error;
             } else if (child->child->next) {
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->child->next->name);
+                LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->child->next->name);
                 goto error;
             }
             /* and now finally get the value */
-            GETVAL(value, child->child, "value");
+            GETVAL(ctx, value, child->child, "value");
             /* check here differs from a generic prefix check, since this prefix
              * don't have to be unique
              */
-            if (lyp_check_identifier(value, LY_IDENT_NAME, NULL, NULL)) {
+            if (lyp_check_identifier(ctx, value, LY_IDENT_NAME, NULL, NULL)) {
                 goto error;
             }
             submodule->prefix = lydict_insert(ctx, value, strlen(value));
@@ -6582,26 +6575,26 @@
             /* counters (statements with n..1 cardinality) */
         } else if (!strcmp(child->name, "import")) {
             if (substmt_group > 1) {
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
-                LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Statement \"%s\" cannot appear after \"%s\" statement.",
+                LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
+                LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Statement \"%s\" cannot appear after \"%s\" statement.",
                        child->name, substmt_prev);
                 goto error;
             }
             substmt_group = 1;
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_imp, trg->imp_size, "imports",
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_imp, trg->imp_size, "imports",
                                           submodule ? "submodule" : "module", error);
             c_imp++;
 
             substmt_prev = "import";
         } else if (!strcmp(child->name, "revision")) {
             if (substmt_group > 3) {
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
-                LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Statement \"%s\" cannot appear after \"%s\" statement.",
+                LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
+                LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Statement \"%s\" cannot appear after \"%s\" statement.",
                        child->name, substmt_prev);
                 goto error;
             }
             substmt_group = 3;
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_rev, trg->rev_size, "revisions",
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_rev, trg->rev_size, "revisions",
                                           submodule ? "submodule" : "module", error);
             c_rev++;
 
@@ -6611,34 +6604,34 @@
             substmt_prev = "revision";
         } else if (!strcmp(child->name, "typedef")) {
             substmt_group = 4;
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_tpdf, trg->tpdf_size, "typedefs",
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_tpdf, trg->tpdf_size, "typedefs",
                                           submodule ? "submodule" : "module", error);
             c_tpdf++;
 
             substmt_prev = "typedef";
         } else if (!strcmp(child->name, "identity")) {
             substmt_group = 4;
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ident, trg->ident_size, "identities",
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ident, trg->ident_size, "identities",
                                           submodule ? "submodule" : "module", error);
             c_ident++;
 
             substmt_prev = "identity";
         } else if (!strcmp(child->name, "include")) {
             if (substmt_group > 1) {
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
-                LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Statement \"%s\" cannot appear after \"%s\" statement.",
+                LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
+                LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Statement \"%s\" cannot appear after \"%s\" statement.",
                        child->name, substmt_prev);
                 goto error;
             }
             substmt_group = 1;
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_inc, trg->inc_size, "includes",
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_inc, trg->inc_size, "includes",
                                           submodule ? "submodule" : "module", error);
             c_inc++;
 
             substmt_prev = "include";
         } else if (!strcmp(child->name, "augment")) {
             substmt_group = 4;
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_aug, trg->augment_size, "augments",
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_aug, trg->augment_size, "augments",
                                           submodule ? "submodule" : "module", error);
             c_aug++;
             /* keep augments separated, processed last */
@@ -6648,7 +6641,7 @@
             substmt_prev = "augment";
         } else if (!strcmp(child->name, "feature")) {
             substmt_group = 4;
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ftrs, trg->features_size, "features",
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ftrs, trg->features_size, "features",
                                           submodule ? "submodule" : "module", error);
             c_ftrs++;
 
@@ -6682,15 +6675,15 @@
             /* optional statements */
         } else if (!strcmp(child->name, "description")) {
             if (substmt_group > 2) {
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
-                LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Statement \"%s\" cannot appear after \"%s\" statement.",
+                LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
+                LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Statement \"%s\" cannot appear after \"%s\" statement.",
                        child->name, substmt_prev);
                 goto error;
             }
             substmt_group = 2;
 
             if (trg->dsc) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
                 goto error;
             }
             if (lyp_yin_parse_subnode_ext(trg, trg, LYEXT_PAR_MODULE, child, LYEXT_SUBSTMT_DESCRIPTION, 0, unres)) {
@@ -6705,15 +6698,15 @@
             substmt_prev = "description";
         } else if (!strcmp(child->name, "reference")) {
             if (substmt_group > 2) {
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
-                LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Statement \"%s\" cannot appear after \"%s\" statement.",
+                LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
+                LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Statement \"%s\" cannot appear after \"%s\" statement.",
                        child->name, substmt_prev);
                 goto error;
             }
             substmt_group = 2;
 
             if (trg->ref) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
                 goto error;
             }
             if (lyp_yin_parse_subnode_ext(trg, trg, LYEXT_PAR_MODULE, child, LYEXT_SUBSTMT_REFERENCE, 0, unres)) {
@@ -6728,15 +6721,15 @@
             substmt_prev = "reference";
         } else if (!strcmp(child->name, "organization")) {
             if (substmt_group > 2) {
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
-                LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Statement \"%s\" cannot appear after \"%s\" statement.",
+                LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
+                LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Statement \"%s\" cannot appear after \"%s\" statement.",
                        child->name, substmt_prev);
                 goto error;
             }
             substmt_group = 2;
 
             if (trg->org) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
                 goto error;
             }
             if (lyp_yin_parse_subnode_ext(trg, trg, LYEXT_PAR_MODULE, child, LYEXT_SUBSTMT_ORGANIZATION, 0, unres)) {
@@ -6751,15 +6744,15 @@
             substmt_prev = "organization";
         } else if (!strcmp(child->name, "contact")) {
             if (substmt_group > 2) {
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
-                LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Statement \"%s\" cannot appear after \"%s\" statement.",
+                LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
+                LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Statement \"%s\" cannot appear after \"%s\" statement.",
                        child->name, substmt_prev);
                 goto error;
             }
             substmt_group = 2;
 
             if (trg->contact) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
                 goto error;
             }
             if (lyp_yin_parse_subnode_ext(trg, trg, LYEXT_PAR_MODULE, child, LYEXT_SUBSTMT_CONTACT, 0, unres)) {
@@ -6774,26 +6767,26 @@
             substmt_prev = "contact";
         } else if (!strcmp(child->name, "yang-version")) {
             if (substmt_group > 0) {
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
-                LOGVAL(LYE_SPEC, LY_VLOG_NONE, NULL, "Statement \"%s\" cannot appear after \"%s\" statement.",
+                LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
+                LOGVAL(ctx, LYE_SPEC, LY_VLOG_NONE, NULL, "Statement \"%s\" cannot appear after \"%s\" statement.",
                        child->name, substmt_prev);
                 goto error;
             }
 
             if (version_flag) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
+                LOGVAL(ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, child->name, yin->name);
                 goto error;
             }
-            GETVAL(value, child, "value");
+            GETVAL(ctx, value, child, "value");
             if (strcmp(value, "1") && strcmp(value, "1.1")) {
-                LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, "yang-version");
+                LOGVAL(ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, "yang-version");
                 goto error;
             }
             version_flag = 1;
             if (!strcmp(value, "1")) {
                 if (submodule) {
                     if (module->version > 1) {
-                        LOGVAL(LYE_INVER, LY_VLOG_NONE, NULL);
+                        LOGVAL(ctx, LYE_INVER, LY_VLOG_NONE, NULL);
                         goto error;
                     }
                     submodule->version = 1;
@@ -6803,7 +6796,7 @@
             } else {
                 if (submodule) {
                     if (module->version < 2) {
-                        LOGVAL(LYE_INVER, LY_VLOG_NONE, NULL);
+                        LOGVAL(ctx, LYE_INVER, LY_VLOG_NONE, NULL);
                         goto error;
                     }
                     submodule->version = 2;
@@ -6820,20 +6813,20 @@
             substmt_prev = "yang-version";
         } else if (!strcmp(child->name, "extension")) {
             substmt_group = 4;
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_ext, trg->extensions_size, "extensions",
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_ext, trg->extensions_size, "extensions",
                                           submodule ? "submodule" : "module", error);
             c_ext++;
 
             substmt_prev = "extension";
         } else if (!strcmp(child->name, "deviation")) {
             substmt_group = 4;
-            YIN_CHECK_ARRAY_OVERFLOW_GOTO(c_dev, trg->deviation_size, "deviations",
+            YIN_CHECK_ARRAY_OVERFLOW_GOTO(ctx, c_dev, trg->deviation_size, "deviations",
                                           submodule ? "submodule" : "module", error);
             c_dev++;
 
             substmt_prev = "deviation";
         } else {
-            LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, child->name);
             goto error;
         }
     }
@@ -6841,23 +6834,23 @@
     /* check for mandatory statements */
     if (submodule) {
         if (!submodule->prefix) {
-            LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "belongs-to", "submodule");
+            LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "belongs-to", "submodule");
             goto error;
         }
         if (!version_flag) {
             /* check version compatibility with the main module */
             if (module->version > 1) {
-                LOGVAL(LYE_INVER, LY_VLOG_NONE, NULL);
+                LOGVAL(ctx, LYE_INVER, LY_VLOG_NONE, NULL);
                 goto error;
             }
         }
     } else {
         if (!trg->ns) {
-            LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "namespace", "module");
+            LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "namespace", "module");
             goto error;
         }
         if (!trg->prefix) {
-            LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "prefix", "module");
+            LOGVAL(ctx, LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "prefix", "module");
             goto error;
         }
     }
@@ -6865,39 +6858,39 @@
     /* allocate arrays for elements with cardinality of 0..n */
     if (c_imp) {
         trg->imp = calloc(c_imp, sizeof *trg->imp);
-        LY_CHECK_ERR_GOTO(!trg->imp, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!trg->imp, LOGMEM(ctx), error);
     }
     if (c_rev) {
         trg->rev = calloc(c_rev, sizeof *trg->rev);
-        LY_CHECK_ERR_GOTO(!trg->rev, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!trg->rev, LOGMEM(ctx), error);
     }
     if (c_tpdf) {
         trg->tpdf = calloc(c_tpdf, sizeof *trg->tpdf);
-        LY_CHECK_ERR_GOTO(!trg->tpdf, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!trg->tpdf, LOGMEM(ctx), error);
     }
     if (c_ident) {
         trg->ident = calloc(c_ident, sizeof *trg->ident);
-        LY_CHECK_ERR_GOTO(!trg->ident, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!trg->ident, LOGMEM(ctx), error);
     }
     if (c_inc) {
         trg->inc = calloc(c_inc, sizeof *trg->inc);
-        LY_CHECK_ERR_GOTO(!trg->inc, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!trg->inc, LOGMEM(ctx), error);
     }
     if (c_aug) {
         trg->augment = calloc(c_aug, sizeof *trg->augment);
-        LY_CHECK_ERR_GOTO(!trg->augment, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!trg->augment, LOGMEM(ctx), error);
     }
     if (c_ftrs) {
         trg->features = calloc(c_ftrs, sizeof *trg->features);
-        LY_CHECK_ERR_GOTO(!trg->features, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!trg->features, LOGMEM(ctx), error);
     }
     if (c_dev) {
         trg->deviation = calloc(c_dev, sizeof *trg->deviation);
-        LY_CHECK_ERR_GOTO(!trg->deviation, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!trg->deviation, LOGMEM(ctx), error);
     }
     if (c_ext) {
         trg->extensions = calloc(c_ext, sizeof *trg->extensions);
-        LY_CHECK_ERR_GOTO(!trg->extensions, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!trg->extensions, LOGMEM(ctx), error);
     }
 
     /* middle part 1 - process revision and then check whether this (sub)module was not already parsed, add it there */
@@ -6911,7 +6904,7 @@
         /* check uniqueness of the revision date - not required by RFC */
         for (i = 0; i < (trg->rev_size - 1); i++) {
             if (!strcmp(trg->rev[i].date, trg->rev[trg->rev_size - 1].date)) {
-                LOGWRN("Module's revisions are not unique (%s).", trg->rev[trg->rev_size - 1].date);
+                LOGWRN(ctx, "Module's revisions are not unique (%s).", trg->rev[trg->rev_size - 1].date);
                 break;
             }
         }
@@ -6990,7 +6983,7 @@
     if (c_extinst) {
         /* some extensions may be already present from the substatements */
         reallocated = realloc(trg->ext, (c_extinst + trg->ext_size) * sizeof *trg->ext);
-        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM, error);
+        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM(ctx), error);
         trg->ext = reallocated;
 
         /* init memory */
@@ -7076,7 +7069,7 @@
         lyxml_free(ctx, revs.child);
     }
     while (exts.child) {
-        lyxml_free(module->ctx, exts.child);
+        lyxml_free(ctx, exts.child);
     }
 
     return ret;
@@ -7086,33 +7079,32 @@
 struct lys_submodule *
 yin_read_submodule(struct lys_module *module, const char *data, struct unres_schema *unres)
 {
+    struct ly_ctx *ctx = module->ctx;
     struct lyxml_elem *yin;
     struct lys_submodule *submodule = NULL;
     const char *value;
 
-    assert(module->ctx);
-
-    yin = lyxml_parse_mem(module->ctx, data, LYXML_PARSE_NOMIXEDCONTENT);
+    yin = lyxml_parse_mem(ctx, data, LYXML_PARSE_NOMIXEDCONTENT);
     if (!yin) {
         return NULL;
     }
 
     /* check root element */
     if (!yin->name || strcmp(yin->name, "submodule")) {
-        LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, yin->name);
+        LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, yin->name);
         goto error;
     }
 
-    GETVAL(value, yin, "name");
-    if (lyp_check_identifier(value, LY_IDENT_NAME, NULL, NULL)) {
+    GETVAL(ctx, value, yin, "name");
+    if (lyp_check_identifier(ctx, value, LY_IDENT_NAME, NULL, NULL)) {
         goto error;
     }
 
     submodule = calloc(1, sizeof *submodule);
-    LY_CHECK_ERR_GOTO(!submodule, LOGMEM, error);
+    LY_CHECK_ERR_GOTO(!submodule, LOGMEM(ctx), error);
 
-    submodule->ctx = module->ctx;
-    submodule->name = lydict_insert(submodule->ctx, value, strlen(value));
+    submodule->ctx = ctx;
+    submodule->name = lydict_insert(ctx, value, strlen(value));
     submodule->type = 1;
     submodule->implemented = module->implemented;
     submodule->belongsto = module;
@@ -7131,24 +7123,24 @@
     lyp_sort_revisions((struct lys_module *)submodule);
 
     /* cleanup */
-    lyxml_free(module->ctx, yin);
-    lyp_check_circmod_pop(module->ctx);
+    lyxml_free(ctx, yin);
+    lyp_check_circmod_pop(ctx);
 
     LOGVRB("Submodule \"%s\" successfully parsed.", submodule->name);
     return submodule;
 
 error:
     /* cleanup */
-    lyxml_free(module->ctx, yin);
+    lyxml_free(ctx, yin);
     if (!submodule) {
-        LOGERR(ly_errno, "Submodule parsing failed.");
+        LOGERR(ctx, ly_errno, "Submodule parsing failed.");
         return NULL;
     }
 
-    LOGERR(ly_errno, "Submodule \"%s\" parsing failed.", submodule->name);
+    LOGERR(ctx, ly_errno, "Submodule \"%s\" parsing failed.", submodule->name);
 
     unres_schema_free((struct lys_module *)submodule, &unres, 0);
-    lyp_check_circmod_pop(module->ctx);
+    lyp_check_circmod_pop(ctx);
     lys_sub_module_remove_devs_augs((struct lys_module *)submodule);
     lys_submodule_module_data_free(submodule);
     lys_submodule_free(submodule, NULL);
@@ -7165,25 +7157,25 @@
     int ret;
 
     unres = calloc(1, sizeof *unres);
-    LY_CHECK_ERR_RETURN(!unres, LOGMEM, NULL);
+    LY_CHECK_ERR_RETURN(!unres, LOGMEM(ctx), NULL);
 
     /* check root element */
     if (!yin->name || strcmp(yin->name, "module")) {
         if (ly_strequal("submodule", yin->name, 0)) {
-            LOGVAL(LYE_SUBMODULE, LY_VLOG_NONE, NULL);
+            LOGVAL(ctx, LYE_SUBMODULE, LY_VLOG_NONE, NULL);
         } else {
-            LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, yin->name);
+            LOGVAL(ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, yin->name);
         }
         goto error;
     }
 
-    GETVAL(value, yin, "name");
-    if (lyp_check_identifier(value, LY_IDENT_NAME, NULL, NULL)) {
+    GETVAL(ctx, value, yin, "name");
+    if (lyp_check_identifier(ctx, value, LY_IDENT_NAME, NULL, NULL)) {
         goto error;
     }
 
     module = calloc(1, sizeof *module);
-    LY_CHECK_ERR_GOTO(!module, LOGMEM, error);
+    LY_CHECK_ERR_GOTO(!module, LOGMEM(ctx), error);
 
     module->ctx = ctx;
     module->name = lydict_insert(ctx, value, strlen(value));
@@ -7267,13 +7259,13 @@
     unres_schema_free(module, &unres, 1);
 
     if (!module) {
-        if (ly_vecode != LYVE_SUBMODULE) {
-            LOGERR(ly_errno, "Module parsing failed.");
+        if (ly_vecode(ctx) != LYVE_SUBMODULE) {
+            LOGERR(ctx, ly_errno, "Module parsing failed.");
         }
         return NULL;
     }
 
-    LOGERR(ly_errno, "Module \"%s\" parsing failed.", module->name);
+    LOGERR(ctx, ly_errno, "Module \"%s\" parsing failed.", module->name);
 
     lyp_check_circmod_pop(ctx);
     lys_sub_module_remove_devs_augs(module);
@@ -7291,7 +7283,7 @@
 
     yin = lyxml_parse_mem(ctx, data, LYXML_PARSE_NOMIXEDCONTENT);
     if (!yin) {
-        LOGERR(ly_errno, "Module parsing failed.");
+        LOGERR(ctx, ly_errno, "Module parsing failed.");
         return NULL;
     }
 
@@ -7313,11 +7305,11 @@
 
     val = lys_ext_complex_get_substmt(stmt, ext, &info);
     if (!val) {
-        LOGVAL(LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, node->name, node->parent->name);
+        LOGVAL(mod->ctx, LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, node->name, node->parent->name);
         return EXIT_FAILURE;
     }
     if (*val) {
-        LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, node->parent->name);
+        LOGVAL(mod->ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, node->parent->name);
         return EXIT_FAILURE;
     }
 
@@ -7327,7 +7319,7 @@
 
     str = lyxml_get_attr(node, "value", NULL);
     if (!str) {
-        LOGVAL(LYE_MISSARG, LY_VLOG_NONE, NULL, "value", node->name);
+        LOGVAL(mod->ctx, LYE_MISSARG, LY_VLOG_NONE, NULL, "value", node->name);
     } else if (true_val && !strcmp(true_val, str)) {
         /* true value */
         *val = 1;
@@ -7336,7 +7328,7 @@
         *val = 2;
     } else {
         /* unknown value */
-        LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, str, node->name);
+        LOGVAL(mod->ctx, LYE_INARG, LY_VLOG_NONE, NULL, str, node->name);
         return EXIT_FAILURE;
     }
 
@@ -7359,11 +7351,11 @@
 
     str = lys_ext_complex_get_substmt(stmt, ext, &info);
     if (!str) {
-        LOGVAL(LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, node->name, node->parent->name);
+        LOGVAL(mod->ctx, LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, node->name, node->parent->name);
         return EXIT_FAILURE;
     }
     if (info->cardinality < LY_STMT_CARD_SOME && *str) {
-        LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, node->parent->name);
+        LOGVAL(mod->ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, node->parent->name);
         return EXIT_FAILURE;
     }
 
@@ -7374,15 +7366,15 @@
         if (!p[0]) {
             /* allocate initial array */
             p[0] = malloc(2 * sizeof(const char *));
-            LY_CHECK_ERR_RETURN(!p[0], LOGMEM, EXIT_FAILURE);
+            LY_CHECK_ERR_RETURN(!p[0], LOGMEM(mod->ctx), EXIT_FAILURE);
             if (stmt == LY_STMT_BELONGSTO) {
                 /* allocate another array for the belongs-to's prefixes */
                 p[1] = malloc(2 * sizeof(const char *));
-                LY_CHECK_ERR_RETURN(!p[1], LOGMEM, EXIT_FAILURE);
+                LY_CHECK_ERR_RETURN(!p[1], LOGMEM(mod->ctx), EXIT_FAILURE);
             } else if (stmt == LY_STMT_ARGUMENT) {
                 /* allocate another array for the yin element */
                 ((uint8_t **)p)[1] = malloc(2 * sizeof(uint8_t));
-                LY_CHECK_ERR_RETURN(!p[1], LOGMEM, EXIT_FAILURE);
+                LY_CHECK_ERR_RETURN(!p[1], LOGMEM(mod->ctx), EXIT_FAILURE);
             }
         } else {
             /* get the index in the array to add new item */
@@ -7402,7 +7394,7 @@
     } else {
         str[c] = lyxml_get_attr(node, argname, NULL);
         if (!str[c]) {
-            LOGVAL(LYE_MISSARG, LY_VLOG_NONE, NULL, argname, node->name);
+            LOGVAL(mod->ctx, LYE_MISSARG, LY_VLOG_NONE, NULL, argname, node->name);
             return EXIT_FAILURE;
         } else {
             str[c] = lydict_insert(mod->ctx, str[c], 0);
@@ -7411,13 +7403,13 @@
         if (stmt == LY_STMT_BELONGSTO) {
             /* get the belongs-to's mandatory prefix substatement */
             if (!node->child) {
-                LOGVAL(LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "prefix", node->name);
+                LOGVAL(mod->ctx, LYE_MISSCHILDSTMT, LY_VLOG_NONE, NULL, "prefix", node->name);
                 return EXIT_FAILURE;
             } else if (strcmp(node->child->name, "prefix")) {
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, node->child->name);
+                LOGVAL(mod->ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->child->name);
                 return EXIT_FAILURE;
             } else if (node->child->next) {
-                LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, node->child->next->name);
+                LOGVAL(mod->ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->child->next->name);
                 return EXIT_FAILURE;
             }
             /* and now finally get the value */
@@ -7428,7 +7420,7 @@
             }
             str[c] = lyxml_get_attr(node->child, "value", ((void *)0));
             if (!str[c]) {
-                LOGVAL(LYE_MISSARG, LY_VLOG_NONE, NULL, "value", node->child->name);
+                LOGVAL(mod->ctx, LYE_MISSARG, LY_VLOG_NONE, NULL, "value", node->child->name);
                 return EXIT_FAILURE;
             }
             str[c] = lydict_insert(mod->ctx, str[c], 0);
@@ -7444,16 +7436,16 @@
             } else {
                 /* get optional yin-element substatement */
                 if (strcmp(node->child->name, "yin-element")) {
-                    LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, node->child->name);
+                    LOGVAL(mod->ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->child->name);
                     return EXIT_FAILURE;
                 } else if (node->child->next) {
-                    LOGVAL(LYE_INSTMT, LY_VLOG_NONE, NULL, node->child->next->name);
+                    LOGVAL(mod->ctx, LYE_INSTMT, LY_VLOG_NONE, NULL, node->child->next->name);
                     return EXIT_FAILURE;
                 } else {
                     /* and now finally get the value */
                     value = lyxml_get_attr(node->child, "value", NULL);
                     if (!value) {
-                        LOGVAL(LYE_MISSARG, LY_VLOG_NONE, NULL, "value", node->child->name);
+                        LOGVAL(mod->ctx, LYE_MISSARG, LY_VLOG_NONE, NULL, "value", node->child->name);
                         return EXIT_FAILURE;
                     }
                     if (ly_strequal(value, "true", 0)) {
@@ -7461,7 +7453,7 @@
                     } else if (ly_strequal(value, "false", 0)) {
                         ((uint8_t *)str)[c] = 2;
                     } else {
-                        LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, str, node->name);
+                        LOGVAL(mod->ctx, LYE_INARG, LY_VLOG_NONE, NULL, str, node->name);
                         return EXIT_FAILURE;
                     }
 
@@ -7476,7 +7468,7 @@
         /* enlarge the array(s) */
         reallocated = realloc(p[0], (c + 2) * sizeof(const char *));
         if (!reallocated) {
-            LOGMEM;
+            LOGMEM(mod->ctx);
             lydict_remove(mod->ctx, p[0][c]);
             p[0][c] = NULL;
             return EXIT_FAILURE;
@@ -7488,7 +7480,7 @@
             /* enlarge the second belongs-to's array with prefixes */
             reallocated = realloc(p[1], (c + 2) * sizeof(const char *));
             if (!reallocated) {
-                LOGMEM;
+                LOGMEM(mod->ctx);
                 lydict_remove(mod->ctx, p[1][c]);
                 p[1][c] = NULL;
                 return EXIT_FAILURE;
@@ -7499,7 +7491,7 @@
             /* enlarge the second argument's array with yin element */
             reallocated = realloc(p[1], (c + 2) * sizeof(uint8_t));
             if (!reallocated) {
-                LOGMEM;
+                LOGMEM(mod->ctx);
                 ((uint8_t *)p[1])[c] = 0;
                 return EXIT_FAILURE;
             }
@@ -7520,11 +7512,11 @@
 
     data = lys_ext_complex_get_substmt(stmt, ext, &info);
     if (!data) {
-        LOGVAL(LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, node->name, node->parent->name);
+        LOGVAL(ext->module->ctx, LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, node->name, node->parent->name);
         return NULL;
     }
     if (info->cardinality < LY_STMT_CARD_SOME && ((*(uint16_t *)data) & mask)) {
-        LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, node->parent->name);
+        LOGVAL(ext->module->ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, node->parent->name);
         return NULL;
     }
 
@@ -7547,14 +7539,14 @@
 
     str = lyxml_get_attr(node, "value", NULL);
     if (!str) {
-        LOGVAL(LYE_MISSARG, LY_VLOG_NONE, NULL, "value", node->name);
+        LOGVAL(mod->ctx, LYE_MISSARG, LY_VLOG_NONE, NULL, "value", node->name);
     } else if (!strcmp(val1_str, str)) {
         *val = *val | val1;
     } else if (!strcmp(val2_str, str)) {
         *val = *val | val2;
     } else {
         /* unknown value */
-        LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, str, node->name);
+        LOGVAL(mod->ctx, LYE_INARG, LY_VLOG_NONE, NULL, str, node->name);
         return EXIT_FAILURE;
     }
     if (lyp_yin_parse_subnode_ext(mod, ext, LYEXT_PAR_EXTINST, node, (LYEXT_SUBSTMT)stmt, 0, unres)) {
@@ -7571,13 +7563,13 @@
 
     snode = lys_ext_complex_get_substmt(stmt, ext, &info);
     if (!snode) {
-        LOGVAL(LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, node->name, node->parent->name);
+        LOGVAL(ext->module->ctx, LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, node->name, node->parent->name);
         return NULL;
     }
     if (info->cardinality < LY_STMT_CARD_SOME) {
         LY_TREE_FOR(*snode, siter) {
             if (stmt == lys_snode2stmt(siter->nodetype)) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, node->parent->name);
+                LOGVAL(ext->module->ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, node->parent->name);
                 return NULL;
             }
         }
@@ -7596,11 +7588,11 @@
 
     data = lys_ext_complex_get_substmt(stmt, ext, &info);
     if (!data) {
-        LOGVAL(LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, node->name, node->parent->name);
+        LOGVAL(ext->module->ctx, LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, node->name, node->parent->name);
         return NULL;
     }
     if (info->cardinality < LY_STMT_CARD_SOME && *data) {
-        LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, node->parent->name);
+        LOGVAL(ext->module->ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, node->parent->name);
         return NULL;
     }
 
@@ -7613,7 +7605,7 @@
         if (!data) {
             /* allocate initial array */
             *p = data = malloc(2 * sizeof(void *));
-            LY_CHECK_ERR_RETURN(!data, LOGMEM, NULL);
+            LY_CHECK_ERR_RETURN(!data, LOGMEM(ext->module->ctx), NULL);
         } else {
             for (c = 0; *data; data++, c++);
         }
@@ -7622,7 +7614,7 @@
     if (p) {
         /* enlarge the array */
         reallocated = realloc(*p, (c + 2) * sizeof(void *));
-        LY_CHECK_ERR_RETURN(!reallocated, LOGMEM, NULL);
+        LY_CHECK_ERR_RETURN(!reallocated, LOGMEM(ext->module->ctx), NULL);
         *p = reallocated;
         data = *p;
         data[c + 1] = NULL;
@@ -7648,17 +7640,17 @@
 
 #define YIN_STORE_VALUE(TYPE, FROM, TO)           \
     *(TYPE **)TO = malloc(sizeof(TYPE));          \
-    if (!*(TYPE **)TO) { LOGMEM; goto error; }    \
+    if (!*(TYPE **)TO) { LOGMEM(mod->ctx); goto error; }    \
     (**(TYPE **)TO) = (TYPE)FROM;
 
 #define YIN_EXTCOMPLEX_GETPLACE(STMT, TYPE)                                          \
     p = lys_ext_complex_get_substmt(STMT, ext, &info);                               \
     if (!p) {                                                                        \
-        LOGVAL(LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, node->name, node->parent->name); \
+        LOGVAL(mod->ctx, LYE_INCHILDSTMT, LY_VLOG_NONE, NULL, node->name, node->parent->name); \
         goto error;                                                                  \
     }                                                                                \
     if (info->cardinality < LY_STMT_CARD_SOME && (*(TYPE*)p)) {                      \
-        LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, node->parent->name);     \
+        LOGVAL(mod->ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, node->parent->name);     \
         goto error;                                                                  \
     }                                                                                \
     pp = NULL; i = 0;                                                                \
@@ -7667,7 +7659,7 @@
         pp = p;                                                                      \
         if (!(*pp)) {                                                                \
             *pp = malloc(2 * sizeof(TYPE)); /* allocate initial array */             \
-            LY_CHECK_ERR_GOTO(!*pp, LOGMEM, error);                                  \
+            LY_CHECK_ERR_GOTO(!*pp, LOGMEM(mod->ctx), error);                        \
         } else {                                                                     \
             for (i = 0; (*(TYPE**)pp)[i]; i++);                                      \
         }                                                                            \
@@ -7677,7 +7669,7 @@
     if (pp) {                                                \
         /* enlarge the array */                              \
         reallocated = realloc(*pp, (i + 2) * sizeof(TYPE*)); \
-        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM, error);      \
+        LY_CHECK_ERR_GOTO(!reallocated, LOGMEM(mod->ctx), error);      \
         *pp = reallocated;                                   \
         (*(TYPE**)pp)[i + 1] = 0;                            \
     }
@@ -7687,9 +7679,9 @@
     if (!FUNC(mod, (struct lys_node*)ext, node, ##ARGS, LYS_PARSE_OPT_CFG_NOINHERIT, unres)) { goto error; }
 #define YIN_EXTCOMPLEX_PARSE_RESTR(STMT)                                             \
     YIN_EXTCOMPLEX_GETPLACE(STMT, struct lys_restr*);                                \
-    GETVAL(value, node, "value");                                                    \
+    GETVAL(mod->ctx, value, node, "value");                                                    \
     *(struct lys_restr **)p = calloc(1, sizeof(struct lys_restr));                   \
-    LY_CHECK_ERR_GOTO(!*(struct lys_restr **)p, LOGMEM, error);                      \
+    LY_CHECK_ERR_GOTO(!*(struct lys_restr **)p, LOGMEM(mod->ctx), error);            \
     (*(struct lys_restr **)p)->expr = lydict_insert(mod->ctx, value, 0);             \
     if (read_restr_substmt(mod, *(struct lys_restr **)p, node, unres)) {             \
         goto error;                                                                  \
@@ -7702,7 +7694,7 @@
         } else if (node->ns == yin->ns && (ext->flags & LYS_YINELEM) && ly_strequal(node->name, ext->def->argument, 1)) {
             /* we have the extension's argument */
             if (ext->arg_value) {
-                LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name);
+                LOGVAL(mod->ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, node->name, yin->name);
                 goto error;
             }
             ext->arg_value = node->content;
@@ -7731,7 +7723,7 @@
             }
             /* allocate type structure */
             (*type) = calloc(1, sizeof **type);
-            LY_CHECK_ERR_GOTO(!*type, LOGMEM, error);
+            LY_CHECK_ERR_GOTO(!*type, LOGMEM(mod->ctx), error);
 
             /* HACK for unres */
             lyxml_unlink(mod->ctx, node);
@@ -7750,7 +7742,7 @@
             }
             /* allocate typedef structure */
             (*pp) = calloc(1, sizeof(struct lys_tpdf));
-            LY_CHECK_ERR_GOTO(!*pp, LOGMEM, error);
+            LY_CHECK_ERR_GOTO(!*pp, LOGMEM(mod->ctx), error);
 
             if (fill_yin_typedef(mod, (struct lys_node *)ext, node, *((struct lys_tpdf **)pp), unres)) {
                 goto error;
@@ -7762,7 +7754,7 @@
             }
             /* allocate iffeature structure */
             (*pp) = calloc(1, sizeof(struct lys_iffeature));
-            LY_CHECK_ERR_GOTO(!*pp, LOGMEM, error);
+            LY_CHECK_ERR_GOTO(!*pp, LOGMEM(mod->ctx), error);
 
             if (fill_yin_iffeature((struct lys_node *)ext, 0, node, *((struct lys_iffeature **)pp), unres)) {
                 goto error;
@@ -7773,7 +7765,7 @@
                 goto error;
             }
 
-            GETVAL(value, node, "value");
+            GETVAL(mod->ctx, value, node, "value");
             if (!strcmp(value, "current")) {
                 *(uint16_t*)p |= LYS_STATUS_CURR;
             } else if (!strcmp(value, "deprecated")) {
@@ -7781,7 +7773,7 @@
             } else if (!strcmp(value, "obsolete")) {
                 *(uint16_t*)p |= LYS_STATUS_OBSLT;
             } else {
-                LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, node->name);
+                LOGVAL(mod->ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, node->name);
                 goto error;
             }
 
@@ -7790,7 +7782,7 @@
             }
         } else if (!strcmp(node->name, "config")) {
             if (yin_parse_extcomplex_flag(mod, node, ext, LY_STMT_MANDATORY, "true", "false", LYS_CONFIG_MASK,
-                                         LYS_CONFIG_W | LYS_CONFIG_SET, LYS_CONFIG_R | LYS_CONFIG_SET, unres)) {
+                                          LYS_CONFIG_W | LYS_CONFIG_SET, LYS_CONFIG_R | LYS_CONFIG_SET, unres)) {
                 goto error;
             }
         } else if (!strcmp(node->name, "argument")) {
@@ -7870,12 +7862,12 @@
         } else if (!strcmp(node->name, "fraction-digits")) {
             YIN_EXTCOMPLEX_GETPLACE(LY_STMT_DIGITS, uint8_t);
 
-            GETVAL(value, node, "value");
+            GETVAL(mod->ctx, value, node, "value");
             v = strtol(value, NULL, 10);
 
             /* range check */
             if (v < 1 || v > 18) {
-                LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, node->name);
+                LOGVAL(mod->ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, node->name);
                 goto error;
             }
 
@@ -7890,7 +7882,7 @@
         } else if (!strcmp(node->name, "max-elements")) {
             YIN_EXTCOMPLEX_GETPLACE(LY_STMT_MAX, uint32_t*);
 
-            GETVAL(value, node, "value");
+            GETVAL(mod->ctx, value, node, "value");
             while (isspace(value[0])) {
                 value++;
             }
@@ -7902,7 +7894,7 @@
                 errno = 0; endptr = NULL;
                 u = strtoul(value, &endptr, 10);
                 if (*endptr || value[0] == '-' || errno || u == 0 || u > UINT32_MAX) {
-                    LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, node->name);
+                    LOGVAL(mod->ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, node->name);
                     goto error;
                 }
             }
@@ -7918,7 +7910,7 @@
         } else if (!strcmp(node->name, "min-elements")) {
             YIN_EXTCOMPLEX_GETPLACE(LY_STMT_MIN, uint32_t*);
 
-            GETVAL(value, node, "value");
+            GETVAL(mod->ctx, value, node, "value");
             while (isspace(value[0])) {
                 value++;
             }
@@ -7928,7 +7920,7 @@
             endptr = NULL;
             u = strtoul(value, &endptr, 10);
             if (*endptr || value[0] == '-' || errno || u > UINT32_MAX) {
-                LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, node->name);
+                LOGVAL(mod->ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, node->name);
                 goto error;
             }
 
@@ -7943,7 +7935,7 @@
         } else if (!strcmp(node->name, "value")) {
             YIN_EXTCOMPLEX_GETPLACE(LY_STMT_VALUE, int32_t*);
 
-            GETVAL(value, node, "value");
+            GETVAL(mod->ctx, value, node, "value");
             while (isspace(value[0])) {
                 value++;
             }
@@ -7953,7 +7945,7 @@
 
             /* range check */
             if (ll < INT32_MIN || ll > INT32_MAX) {
-                LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, node->name);
+                LOGVAL(mod->ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, node->name);
                 goto error;
             }
 
@@ -7968,12 +7960,12 @@
         } else if (!strcmp(node->name, "position")) {
             YIN_EXTCOMPLEX_GETPLACE(LY_STMT_POSITION, uint32_t*);
 
-            GETVAL(value, node, "value");
+            GETVAL(mod->ctx, value, node, "value");
             ll = strtoll(value, NULL, 10);
 
             /* range check */
             if (ll < 0 || ll > UINT32_MAX) {
-                LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, value, node->name);
+                LOGVAL(mod->ctx, LYE_INARG, LY_VLOG_NONE, NULL, value, node->name);
                 goto error;
             }
 
@@ -8008,7 +8000,7 @@
             YIN_EXTCOMPLEX_GETPLACE(LY_STMT_REVISION, struct lys_revision*);
 
             *(struct lys_revision**)p = calloc(1, sizeof(struct lys_revision));
-            LY_CHECK_ERR_GOTO(!*(struct lys_revision**)p, LOGMEM, error);
+            LY_CHECK_ERR_GOTO(!*(struct lys_revision**)p, LOGMEM(mod->ctx), error);
             if (fill_yin_revision(mod, node, *(struct lys_revision**)p, unres)) {
                 goto error;
             }
@@ -8017,7 +8009,7 @@
             if (pp) {
                 for (j = 0; j < i; j++) {
                     if (!strcmp((*(struct lys_revision***)pp)[j]->date, (*(struct lys_revision**)p)->date)) {
-                        LOGWRN("Module's revisions are not unique (%s).", (*(struct lys_revision**)p)->date);
+                        LOGWRN(mod->ctx, "Module's revisions are not unique (%s).", (*(struct lys_revision**)p)->date);
                     }
                 }
             }
@@ -8027,7 +8019,7 @@
             YIN_EXTCOMPLEX_GETPLACE(LY_STMT_UNIQUE, struct lys_unique*);
 
             *(struct lys_unique**)p = calloc(1, sizeof(struct lys_unique));
-            LY_CHECK_ERR_GOTO(!*(struct lys_unique**)p, LOGMEM, error);
+            LY_CHECK_ERR_GOTO(!*(struct lys_unique**)p, LOGMEM(mod->ctx), error);
             if (fill_yin_unique(mod, (struct lys_node*)ext, node, *(struct lys_unique**)p, unres)) {
                 goto error;
             }
@@ -8073,20 +8065,20 @@
             }
             /* allocate structure for must */
             (*pp) = calloc(1, sizeof(struct lys_restr));
-            LY_CHECK_ERR_GOTO(!*pp, LOGMEM, error);
+            LY_CHECK_ERR_GOTO(!*pp, LOGMEM(mod->ctx), error);
 
             if (fill_yin_must(mod, node, *((struct lys_restr **)pp), unres)) {
                 goto error;
             }
         } else if (!strcmp(node->name, "pattern")) {
             YIN_EXTCOMPLEX_GETPLACE(LY_STMT_PATTERN, struct lys_restr*);
-            GETVAL(value, node, "value");
-            if (lyp_check_pattern(value, NULL)) {
+            GETVAL(mod->ctx, value, node, "value");
+            if (lyp_check_pattern(mod->ctx, value, NULL)) {
                 goto error;
             }
 
             *(struct lys_restr **)p = calloc(1, sizeof(struct lys_restr));
-            LY_CHECK_ERR_GOTO(!*(struct lys_restr **)p, LOGMEM, error);
+            LY_CHECK_ERR_GOTO(!*(struct lys_restr **)p, LOGMEM(mod->ctx), error);
             (*(struct lys_restr **)p)->expr = lydict_insert(mod->ctx, value, 0);
 
             modifier = 0x06; /* ACK */
@@ -8095,15 +8087,15 @@
                 LY_TREE_FOR(node->child, child) {
                     if (child->ns && !strcmp(child->ns->value, LY_NSYIN) && !strcmp(child->name, "modifier")) {
                         if (name) {
-                            LOGVAL(LYE_TOOMANY, LY_VLOG_NONE, NULL, "modifier", node->name);
+                            LOGVAL(mod->ctx, LYE_TOOMANY, LY_VLOG_NONE, NULL, "modifier", node->name);
                             goto error;
                         }
 
-                        GETVAL(name, child, "value");
+                        GETVAL(mod->ctx, name, child, "value");
                         if (!strcmp(name, "invert-match")) {
                             modifier = 0x15; /* NACK */
                         } else {
-                            LOGVAL(LYE_INARG, LY_VLOG_NONE, NULL, name, "modifier");
+                            LOGVAL(mod->ctx, LYE_INARG, LY_VLOG_NONE, NULL, name, "modifier");
                             goto error;
                         }
                         /* get extensions of the modifier */
@@ -8117,7 +8109,7 @@
 
             /* store the value: modifier byte + value + terminating NULL byte */
             (*(struct lys_restr **)p)->expr = malloc((strlen(value) + 2) * sizeof(char));
-            LY_CHECK_ERR_GOTO(!(*(struct lys_restr **)p)->expr, LOGMEM, error);
+            LY_CHECK_ERR_GOTO(!(*(struct lys_restr **)p)->expr, LOGMEM(mod->ctx), error);
             ((char *)(*(struct lys_restr **)p)->expr)[0] = modifier;
             strcpy(&((char *)(*(struct lys_restr **)p)->expr)[1], value);
             lydict_insert_zc(mod->ctx, (char *)(*(struct lys_restr **)p)->expr);
@@ -8131,9 +8123,7 @@
         } else if (!strcmp(node->name, "range")) {
             YIN_EXTCOMPLEX_PARSE_RESTR(LY_STMT_RANGE);
         } else {
-            LOGERR(LY_SUCCESS, "Extension's substatement \"%s\" not supported.", node->name);
-            //LOGERR(LY_EINT, "Extension's substatement \"%s\" not supported.", node->name);
-            //return EXIT_FAILURE;
+            LOGERR(mod->ctx, ly_errno, "Extension's substatement \"%s\" not supported.", node->name);
         }
         lyxml_free(mod->ctx, node);
     }
