Merge branch 'master' into devel
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fd10129..21b60ae 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -61,12 +61,12 @@
 # set version of the project
 set(LIBYANG_MAJOR_VERSION 2)
 set(LIBYANG_MINOR_VERSION 0)
-set(LIBYANG_MICRO_VERSION 164)
+set(LIBYANG_MICRO_VERSION 185)
 set(LIBYANG_VERSION ${LIBYANG_MAJOR_VERSION}.${LIBYANG_MINOR_VERSION}.${LIBYANG_MICRO_VERSION})
 # set version of the library
 set(LIBYANG_MAJOR_SOVERSION 2)
-set(LIBYANG_MINOR_SOVERSION 18)
-set(LIBYANG_MICRO_SOVERSION 6)
+set(LIBYANG_MINOR_SOVERSION 20)
+set(LIBYANG_MICRO_SOVERSION 7)
 set(LIBYANG_SOVERSION_FULL ${LIBYANG_MAJOR_SOVERSION}.${LIBYANG_MINOR_SOVERSION}.${LIBYANG_MICRO_SOVERSION})
 set(LIBYANG_SOVERSION ${LIBYANG_MAJOR_SOVERSION})
 
@@ -453,7 +453,7 @@
 
 # generate API/ABI report
 if ("${BUILD_TYPE_UPPER}" STREQUAL "ABICHECK")
-    lib_abi_check(yang "${headers}" ${LIBYANG_SOVERSION_FULL} eb31520ac763ba67e278184b5996267a04e98f15)
+    lib_abi_check(yang "${headers}" ${LIBYANG_SOVERSION_FULL} 22f8e17d28a34bfaf8ba1b8f067d4cbfe373e20b)
 endif()
 
 # source code format target for Makefile
diff --git a/src/diff.c b/src/diff.c
index a283e2a..a3ad411 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -26,6 +26,7 @@
 #include "compat.h"
 #include "context.h"
 #include "log.h"
+#include "plugins_exts.h"
 #include "plugins_types.h"
 #include "set.h"
 #include "tree.h"
@@ -961,20 +962,20 @@
             *first_node = anchor;
         }
     } else {
-        if ((*first_node)->schema->flags & LYS_KEY) {
-            assert(parent_node && (parent_node->schema->nodetype == LYS_LIST));
+        /* find the first instance */
+        ret = lyd_find_sibling_val(*first_node, new_node->schema, NULL, 0, &anchor);
+        LY_CHECK_RET(ret && (ret != LY_ENOTFOUND), ret);
 
-            /* find last key */
-            anchor = *first_node;
-            while (anchor->next && (anchor->next->schema->flags & LYS_KEY)) {
-                anchor = anchor->next;
+        if (anchor) {
+            /* insert before the first instance */
+            LY_CHECK_RET(lyd_insert_before(anchor, new_node));
+            if ((*first_node)->prev->next) {
+                assert(!new_node->prev->next);
+                *first_node = new_node;
             }
-            /* insert after the last key */
-            LY_CHECK_RET(lyd_insert_after(anchor, new_node));
         } else {
-            /* insert at the beginning */
-            LY_CHECK_RET(lyd_insert_before(*first_node, new_node));
-            *first_node = new_node;
+            /* insert anywhere */
+            LY_CHECK_RET(lyd_insert_sibling(*first_node, new_node, first_node));
         }
     }
 
@@ -1076,7 +1077,11 @@
         /* insert it at the end */
         ret = 0;
         if (parent_node) {
-            ret = lyd_insert_child(parent_node, match);
+            if (match->flags & LYD_EXT) {
+                ret = lyd_insert_ext(parent_node, match);
+            } else {
+                ret = lyd_insert_child(parent_node, match);
+            }
         } else {
             ret = lyd_insert_sibling(*first_node, match, first_node);
         }
diff --git a/src/lyb.h b/src/lyb.h
index 165dfe5..67f76c7 100644
--- a/src/lyb.h
+++ b/src/lyb.h
@@ -51,7 +51,7 @@
  sb          = siblings_start
  se          = siblings_end
  siblings    = zero-LYB_SIZE_BYTES | (sb instance+ se)
- instance    = model hash node
+ instance    = node_type model hash node
  model       = 16bit_zero | (model_name_length model_name revision)
  node        = opaq | leaflist | list | any | inner | leaf
  opaq        = opaq_data siblings
@@ -66,6 +66,16 @@
  */
 
 /**
+ * @brief LYB data node type
+ */
+enum lylyb_node_type {
+    LYB_NODE_TOP,   /**< top-level node */
+    LYB_NODE_CHILD, /**< child node with a parent */
+    LYB_NODE_OPAQ,  /**< opaque node */
+    LYB_NODE_EXT    /**< nested extension data node */
+};
+
+/**
  * @brief LYB format parser context
  */
 struct lylyb_ctx {
@@ -101,7 +111,7 @@
 #define LYB_SIBLING_STEP 4
 
 /* current LYB format version */
-#define LYB_VERSION_NUM 0x03
+#define LYB_VERSION_NUM 0x04
 
 /* LYB format version mask of the header byte */
 #define LYB_VERSION_MASK 0x0F
diff --git a/src/out.c b/src/out.c
index c4c80d9..da691a9 100644
--- a/src/out.c
+++ b/src/out.c
@@ -39,8 +39,8 @@
 #define REALLOC_CHUNK(NEW_SIZE) \
     NEW_SIZE + (1024 - (NEW_SIZE % 1024))
 
-ly_bool
-ly_should_print(const struct lyd_node *node, uint32_t options)
+LIBYANG_API_DEF ly_bool
+lyd_node_should_print(const struct lyd_node *node, uint32_t options)
 {
     const struct lyd_node *elem;
 
@@ -63,7 +63,7 @@
 
         /* avoid empty default containers */
         LYD_TREE_DFS_BEGIN(node, elem) {
-            if ((elem != node) && ly_should_print(elem, options)) {
+            if ((elem != node) && lyd_node_should_print(elem, options)) {
                 return 1;
             }
             assert(elem->flags & LYD_DEFAULT);
diff --git a/src/out_internal.h b/src/out_internal.h
index 14f74cf..93ba171 100644
--- a/src/out_internal.h
+++ b/src/out_internal.h
@@ -57,15 +57,6 @@
 };
 
 /**
- * @brief Check whether the node should even be printed.
- *
- * @param[in] node Node to check.
- * @param[in] options Printer options.
- * @return false (no, it should not be printed) or true (yes, it is supposed to be printed)
- */
-ly_bool ly_should_print(const struct lyd_node *node, uint32_t options);
-
-/**
  * @brief Generic printer of the given format string into the specified output.
  *
  * Does not reset printed bytes. Adds to printed bytes.
diff --git a/src/parser_json.c b/src/parser_json.c
index c967063..2555a6b 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -183,80 +183,6 @@
 }
 
 /**
- * @brief Try to parse data with a parent based on an extension instance.
- *
- * @param[in] lydctx JSON data parser context.
- * @param[in,out] parent Parent node where the children are inserted.
- * @return LY_SUCCESS on success;
- * @return LY_ENOT if no extension instance parsed the data;
- * @return LY_ERR on error.
- */
-static LY_ERR
-lydjson_nested_ext(struct lyd_json_ctx *lydctx, struct lyd_node *parent)
-{
-    LY_ERR r;
-    struct ly_in in_bck, in_start, in_ext;
-    LY_ARRAY_COUNT_TYPE u;
-    struct lysc_ext_instance *nested_exts = NULL;
-    lyplg_ext_data_parse_clb ext_parse_cb;
-    struct lyd_ctx_ext_val *ext_val;
-    uint32_t quot_count;
-
-    /* backup current input */
-    in_bck = *lydctx->jsonctx->in;
-
-    /* go back in the input for extension parsing */
-    in_start = *lydctx->jsonctx->in;
-    assert(lyjson_ctx_status(lydctx->jsonctx, 0) == LYJSON_OBJECT);
-    quot_count = 0;
-    do {
-        --in_start.current;
-        if ((in_start.current[0] == '\"') && (in_start.current[-1] != '\\')) {
-            ++quot_count;
-        }
-        if (in_start.current == in_start.start) {
-            /* invalid JSON */
-            return LY_ENOT;
-        }
-    } while (quot_count < 2);
-
-    /* check if there are any nested extension instances */
-    if (parent && parent->schema) {
-        nested_exts = parent->schema->exts;
-    }
-    LY_ARRAY_FOR(nested_exts, u) {
-        /* prepare the input and try to parse this extension data */
-        in_ext = in_start;
-        ext_parse_cb = nested_exts[u].def->plugin->parse;
-        r = ext_parse_cb(&in_ext, LYD_JSON, &nested_exts[u], parent, lydctx->parse_opts | LYD_PARSE_ONLY);
-        if (!r) {
-            /* data successfully parsed, remember for validation */
-            if (!(lydctx->parse_opts & LYD_PARSE_ONLY)) {
-                ext_val = malloc(sizeof *ext_val);
-                LY_CHECK_ERR_RET(!ext_val, LOGMEM(lydctx->jsonctx->ctx), LY_EMEM);
-                ext_val->ext = &nested_exts[u];
-                ext_val->sibling = lyd_child_no_keys(parent);
-                LY_CHECK_RET(ly_set_add(&lydctx->ext_val, ext_val, 1, NULL));
-            }
-
-            /* adjust the jsonctx accordingly */
-            *lydctx->jsonctx->in = in_ext;
-            LYJSON_STATUS_PUSH_RET(lydctx->jsonctx, LYJSON_OBJECT_CLOSED);
-            LY_CHECK_RET(lyjson_ctx_next(lydctx->jsonctx, NULL));
-            return LY_SUCCESS;
-        } else if (r != LY_ENOT) {
-            /* fatal error */
-            return r;
-        }
-        /* data was not from this module, continue */
-    }
-
-    /* no extensions or none matched, restore input */
-    *lydctx->jsonctx->in = in_bck;
-    return LY_ENOT;
-}
-
-/**
  * @brief Skip the currently open JSON object/array
  * @param[in] jsonctx JSON context with the input data to skip.
  * @return LY_ERR value.
@@ -303,27 +229,28 @@
  * @param[in] name Requested node's name.
  * @param[in] name_len Length of the @p name.
  * @param[in] parent Parent of the node being processed, can be NULL in case of top-level.
- * @param[out] snode_p Found schema node corresponding to the input parameters. If NULL, parse as an opaque node.
+ * @param[out] snode Found schema node corresponding to the input parameters. If NULL, parse as an opaque node.
+ * @param[out] ext Extension instance that provided @p snode, if any.
  * @return LY_SUCCES on success.
  * @return LY_ENOT if the whole object was parsed (skipped or as an extension).
  * @return LY_ERR on error.
  */
 static LY_ERR
 lydjson_get_snode(struct lyd_json_ctx *lydctx, ly_bool is_attr, const char *prefix, size_t prefix_len, const char *name,
-        size_t name_len, struct lyd_node *parent, const struct lysc_node **snode_p)
+        size_t name_len, struct lyd_node *parent, const struct lysc_node **snode, struct lysc_ext_instance **ext)
 {
     LY_ERR ret = LY_SUCCESS, r;
     struct lys_module *mod = NULL;
     uint32_t getnext_opts = lydctx->int_opts & LYD_INTOPT_REPLY ? LYS_GETNEXT_OUTPUT : 0;
 
-    /* init return value */
-    *snode_p = NULL;
+    *snode = NULL;
+    *ext = NULL;
 
     LOG_LOCSET(NULL, parent, NULL, NULL);
 
-    /* get the element module */
+    /* get the element module, prefer parent context because of extensions */
     if (prefix_len) {
-        mod = ly_ctx_get_module_implemented2(lydctx->jsonctx->ctx, prefix, prefix_len);
+        mod = ly_ctx_get_module_implemented2(parent ? LYD_CTX(parent) : lydctx->jsonctx->ctx, prefix, prefix_len);
     } else if (parent) {
         if (parent->schema) {
             mod = parent->schema->module;
@@ -336,13 +263,9 @@
     }
     if (!mod) {
         /* check for extension data */
-        r = lydjson_nested_ext(lydctx, parent);
-        if (!r) {
-            /* successfully parsed */
-            ret = LY_ENOT;
-            goto cleanup;
-        } else if (r != LY_ENOT) {
-            /* error */
+        r = ly_nested_ext_schema(parent, NULL, prefix, prefix_len, LY_VALUE_JSON, NULL, name, name_len, snode, ext);
+        if (r != LY_ENOT) {
+            /* success or error */
             ret = r;
             goto cleanup;
         }
@@ -366,19 +289,15 @@
     /* get the schema node */
     if (mod && (!parent || parent->schema)) {
         if (!parent && lydctx->ext) {
-            *snode_p = lysc_ext_find_node(lydctx->ext, mod, name, name_len, 0, getnext_opts);
+            *snode = lysc_ext_find_node(lydctx->ext, mod, name, name_len, 0, getnext_opts);
         } else {
-            *snode_p = lys_find_child(parent ? parent->schema : NULL, mod, name, name_len, 0, getnext_opts);
+            *snode = lys_find_child(parent ? parent->schema : NULL, mod, name, name_len, 0, getnext_opts);
         }
-        if (!*snode_p) {
+        if (!*snode) {
             /* check for extension data */
-            r = lydjson_nested_ext(lydctx, parent);
-            if (!r) {
-                /* successfully parsed */
-                ret = LY_ENOT;
-                goto cleanup;
-            } else if (r != LY_ENOT) {
-                /* error */
+            r = ly_nested_ext_schema(parent, NULL, prefix, prefix_len, LY_VALUE_JSON, NULL, name, name_len, snode, ext);
+            if (r != LY_ENOT) {
+                /* success or error */
                 ret = r;
                 goto cleanup;
             }
@@ -413,7 +332,7 @@
             }
         } else {
             /* check that schema node is valid and can be used */
-            ret = lyd_parser_check_schema((struct lyd_ctx *)lydctx, *snode_p);
+            ret = lyd_parser_check_schema((struct lyd_ctx *)lydctx, *snode);
         }
     }
 
@@ -634,6 +553,7 @@
 {
     LY_ERR ret = LY_SUCCESS;
     struct lyd_node *node, *attr, *next, *meta_iter;
+    struct lysc_ext_instance *ext;
     uint64_t instance = 0;
     const char *prev = NULL;
     uint32_t log_location_items = 0;
@@ -704,8 +624,7 @@
                 lydjson_parse_name(meta_container->name.name, strlen(meta_container->name.name), &name, &name_len,
                         &prefix, &prefix_len, &is_attr);
                 assert(is_attr);
-                ret = lydjson_get_snode(lydctx, is_attr, prefix, prefix_len, name, name_len, lyd_parent(*first_p), &snode);
-                assert(ret == LY_SUCCESS);
+                lydjson_get_snode(lydctx, is_attr, prefix, prefix_len, name, name_len, lyd_parent(*first_p), &snode, &ext);
 
                 if (snode != node->schema) {
                     continue;
@@ -742,10 +661,10 @@
                         goto cleanup;
                     }
                 }
-                /* add/correct flags */
-                lyd_parse_set_data_flags(node, &lydctx->node_when, &node->meta, lydctx->parse_opts);
 
-                /* done */
+                /* add/correct flags */
+                ret = lyd_parse_set_data_flags(node, &node->meta, (struct lyd_ctx *)lydctx, ext);
+                LY_CHECK_GOTO(ret, cleanup);
                 break;
             }
         }
@@ -929,7 +848,8 @@
             LY_CHECK_GOTO(ret, cleanup);
 
             /* add/correct flags */
-            lyd_parse_set_data_flags(node, &lydctx->node_when, &meta, lydctx->parse_opts);
+            ret = lyd_parse_set_data_flags(node, &meta, (struct lyd_ctx *)lydctx, NULL);
+            LY_CHECK_GOTO(ret, cleanup);
         } else {
             /* create attribute */
             const char *module_name;
@@ -982,13 +902,19 @@
  * @param[in,out] first_p Pointer to the first sibling node in case of top-level.
  * @param[in,out] node_p pointer to the new node to insert, after the insert is done, pointer is set to NULL.
  * @param[in] last If set, always insert at the end.
+ * @param[in] ext Extension instance of @p node_p, if any.
  */
 static void
-lydjson_maintain_children(struct lyd_node *parent, struct lyd_node **first_p, struct lyd_node **node_p, ly_bool last)
+lydjson_maintain_children(struct lyd_node *parent, struct lyd_node **first_p, struct lyd_node **node_p, ly_bool last,
+        struct lysc_ext_instance *ext)
 {
     if (*node_p) {
         /* insert, keep first pointer correct */
-        lyd_insert_node(parent, first_p, *node_p, last);
+        if (ext) {
+            lyd_insert_ext(parent, *node_p);
+        } else {
+            lyd_insert_node(parent, first_p, *node_p, last);
+        }
         if (first_p) {
             if (parent) {
                 *first_p = lyd_child(parent);
@@ -1116,7 +1042,7 @@
 
         /* continue with the next instance */
         assert(node_p);
-        lydjson_maintain_children(parent, first_p, node_p, lydctx->parse_opts & LYD_PARSE_ORDERED ? 1 : 0);
+        lydjson_maintain_children(parent, first_p, node_p, lydctx->parse_opts & LYD_PARSE_ORDERED ? 1 : 0, NULL);
         LY_CHECK_RET(lydjson_create_opaq(lydctx, name, name_len, prefix, prefix_len, parent, status_inner_p, node_p));
     }
 
@@ -1250,6 +1176,7 @@
  * @param[in] lydctx JSON data parser context. When the function returns, the context is in the same state
  * as before calling, despite it is necessary to process input data for checking.
  * @param[in] snode Schema node corresponding to the member currently being processed in the context.
+ * @param[in] ext Extension instance of @p snode, if any.
  * @param[in,out] status JSON parser status, is updated.
  * @param[out] node Parsed data (or opaque) node.
  * @return LY_SUCCESS if a node was successfully parsed,
@@ -1257,8 +1184,8 @@
  * @return LY_ERR on other errors.
  */
 static LY_ERR
-lydjson_parse_any(struct lyd_json_ctx *lydctx, const struct lysc_node *snode, enum LYJSON_PARSER_STATUS *status,
-        struct lyd_node **node)
+lydjson_parse_any(struct lyd_json_ctx *lydctx, const struct lysc_node *snode, struct lysc_ext_instance *ext,
+        enum LYJSON_PARSER_STATUS *status, struct lyd_node **node)
 {
     LY_ERR r;
     uint32_t prev_parse_opts, prev_int_opts;
@@ -1294,7 +1221,7 @@
          * process data as opaq nodes */
         prev_parse_opts = lydctx->parse_opts;
         lydctx->parse_opts &= ~LYD_PARSE_STRICT;
-        lydctx->parse_opts |= LYD_PARSE_OPAQ;
+        lydctx->parse_opts |= LYD_PARSE_OPAQ | (ext ? LYD_PARSE_ONLY : 0);
         prev_int_opts = lydctx->int_opts;
         lydctx->int_opts |= LYD_INTOPT_ANY | LYD_INTOPT_WITH_SIBLINGS;
 
@@ -1382,6 +1309,7 @@
  * @param[in] parent Data parent of the subtree, must be set if @p first is not.
  * @param[in,out] first_p Pointer to the variable holding the first top-level sibling, must be set if @p parent is not.
  * @param[in] snode Schema node corresponding to the member currently being processed in the context.
+ * @param[in] ext Extension instance of @p snode, if any.
  * @param[in] name Parsed JSON node name.
  * @param[in] name_len Lenght of @p name.
  * @param[in] prefix Parsed JSON node prefix.
@@ -1394,11 +1322,12 @@
  */
 static LY_ERR
 lydjson_parse_instance(struct lyd_json_ctx *lydctx, struct lyd_node *parent, struct lyd_node **first_p,
-        const struct lysc_node *snode, const char *name, size_t name_len, const char *prefix, size_t prefix_len,
-        enum LYJSON_PARSER_STATUS *status, struct lyd_node **node)
+        const struct lysc_node *snode, struct lysc_ext_instance *ext, const char *name, size_t name_len,
+        const char *prefix, size_t prefix_len, enum LYJSON_PARSER_STATUS *status, struct lyd_node **node)
 {
     LY_ERR ret;
     uint32_t type_hints = 0;
+    uint32_t prev_parse_opts;
 
     ret = lydjson_data_check_opaq(lydctx, snode, &type_hints);
     if (ret == LY_SUCCESS) {
@@ -1429,6 +1358,12 @@
 
             LOG_LOCSET(snode, *node, NULL, NULL);
 
+            prev_parse_opts = lydctx->parse_opts;
+            if (ext) {
+                /* only parse these extension data and validate afterwards */
+                lydctx->parse_opts |= LYD_PARSE_ONLY;
+            }
+
             /* process children */
             while ((*status != LYJSON_OBJECT_CLOSED) && (*status != LYJSON_OBJECT_EMPTY)) {
                 ret = lydjson_subtree_r(lydctx, *node, lyd_node_child_p(*node), NULL);
@@ -1436,6 +1371,9 @@
                 *status = lyjson_ctx_status(lydctx->jsonctx, 0);
             }
 
+            /* restore options */
+            lydctx->parse_opts = prev_parse_opts;
+
             /* finish linking metadata */
             ret = lydjson_metadata_finish(lydctx, lyd_node_child_p(*node));
             LY_CHECK_ERR_RET(ret, LOG_LOCBACK(1, 1, 0, 0), ret);
@@ -1460,11 +1398,11 @@
             LOG_LOCBACK(1, 1, 0, 0);
         } else {
             /* create any node */
-            LY_CHECK_RET(lydjson_parse_any(lydctx, snode, status, node));
+            LY_CHECK_RET(lydjson_parse_any(lydctx, snode, ext, status, node));
         }
 
         /* add/correct flags */
-        lyd_parse_set_data_flags(*node, &lydctx->node_when, &(*node)->meta, lydctx->parse_opts);
+        lyd_parse_set_data_flags(*node, &(*node)->meta, (struct lyd_ctx *)lydctx, ext);
     } else if (ret == LY_ENOT) {
         /* parse it again as an opaq node */
         ret = lydjson_parse_opaq(lydctx, name, name_len, prefix, prefix_len, parent, status, status, first_p, node);
@@ -1498,6 +1436,7 @@
     size_t name_len, prefix_len = 0;
     ly_bool is_meta = 0, parse_subtree;
     const struct lysc_node *snode = NULL;
+    struct lysc_ext_instance *ext;
     struct lyd_node *node = NULL, *attr_node = NULL;
     const struct ly_ctx *ctx = lydctx->jsonctx->ctx;
     char *value = NULL;
@@ -1515,7 +1454,7 @@
 
     if (!is_meta || name_len || prefix_len) {
         /* get the schema node */
-        r = lydjson_get_snode(lydctx, is_meta, prefix, prefix_len, name, name_len, parent, &snode);
+        r = lydjson_get_snode(lydctx, is_meta, prefix, prefix_len, name, name_len, parent, &snode, &ext);
         if (r == LY_ENOT) {
             /* data parsed */
             goto cleanup;
@@ -1574,6 +1513,10 @@
                 expected = "name/array of objects";
             }
 
+            if (status == LYJSON_ARRAY_EMPTY) {
+                /* no instances, skip */
+                break;
+            }
             LY_CHECK_GOTO(status != LYJSON_ARRAY, representation_error);
 
             /* move into array */
@@ -1582,15 +1525,14 @@
 
             /* process all the values/objects */
             do {
-                lydjson_maintain_children(parent, first_p, &node, lydctx->parse_opts & LYD_PARSE_ORDERED ? 1 : 0);
-
-                ret = lydjson_parse_instance(lydctx, parent, first_p, snode, name, name_len, prefix, prefix_len,
+                ret = lydjson_parse_instance(lydctx, parent, first_p, snode, ext, name, name_len, prefix, prefix_len,
                         &status, &node);
                 if (ret == LY_ENOT) {
                     goto representation_error;
                 } else if (ret) {
                     goto cleanup;
                 }
+                lydjson_maintain_children(parent, first_p, &node, lydctx->parse_opts & LYD_PARSE_ORDERED ? 1 : 0, ext);
 
                 /* move after the item(s) */
                 LY_CHECK_GOTO(ret = lyjson_ctx_next(lydctx->jsonctx, &status), cleanup);
@@ -1615,7 +1557,8 @@
             }
 
             /* process the value/object */
-            ret = lydjson_parse_instance(lydctx, parent, first_p, snode, name, name_len, prefix, prefix_len, &status, &node);
+            ret = lydjson_parse_instance(lydctx, parent, first_p, snode, ext, name, name_len, prefix, prefix_len,
+                    &status, &node);
             if (ret == LY_ENOT) {
                 goto representation_error;
             } else if (ret) {
@@ -1631,10 +1574,10 @@
     }
 
     /* finally connect the parsed node */
-    lydjson_maintain_children(parent, first_p, &node, lydctx->parse_opts & LYD_PARSE_ORDERED ? 1 : 0);
+    lydjson_maintain_children(parent, first_p, &node, lydctx->parse_opts & LYD_PARSE_ORDERED ? 1 : 0, ext);
 
     /* rememeber a successfully parsed node */
-    if (parsed) {
+    if (parsed && node) {
         ly_set_add(parsed, node, 1, NULL);
     }
 
diff --git a/src/parser_lyb.c b/src/parser_lyb.c
index 43eafc1..db68205 100644
--- a/src/parser_lyb.c
+++ b/src/parser_lyb.c
@@ -30,6 +30,7 @@
 #include "log.h"
 #include "parser_data.h"
 #include "parser_internal.h"
+#include "plugins_exts.h"
 #include "set.h"
 #include "tree.h"
 #include "tree_data.h"
@@ -331,67 +332,86 @@
 }
 
 /**
- * @brief Parse YANG model info.
+ * @brief Read YANG model info.
  *
  * @param[in] lybctx LYB context.
- * @param[in] parse_options Flag with options for parsing.
- * @param[out] model Parsed module.
+ * @param[out] mod_name Module name, if any.
+ * @param[out] mod_rev Module revision, "" if none.
  * @return LY_ERR value.
  */
 static LY_ERR
-lyb_parse_model(struct lylyb_ctx *lybctx, uint32_t parse_options, const struct lys_module **model)
+lyb_read_model(struct lylyb_ctx *lybctx, char **mod_name, char mod_rev[])
 {
-    LY_ERR ret = LY_SUCCESS;
-    const struct lys_module *mod = NULL;
-    char *mod_name = NULL, mod_rev[LY_REV_SIZE];
     uint16_t rev, length;
 
-    lyb_read_number(&length, 2, 2, lybctx);
+    *mod_name = NULL;
+    mod_rev[0] = '\0';
 
-    if (length) {
-        mod_name = malloc((length + 1) * sizeof *mod_name);
-        LY_CHECK_ERR_RET(!mod_name, LOGMEM(lybctx->ctx), LY_EMEM);
-        lyb_read(((uint8_t *)mod_name), length, lybctx);
-        mod_name[length] = '\0';
-    } else {
-        goto cleanup;
+    lyb_read_number(&length, 2, 2, lybctx);
+    if (!length) {
+        return LY_SUCCESS;
     }
 
-    /* revision */
+    /* module name */
+    *mod_name = malloc(length + 1);
+    LY_CHECK_ERR_RET(!*mod_name, LOGMEM(lybctx->ctx), LY_EMEM);
+    lyb_read(((uint8_t *)*mod_name), length, lybctx);
+    (*mod_name)[length] = '\0';
+
+    /* module revision */
     lyb_read_number(&rev, sizeof rev, 2, lybctx);
 
     if (rev) {
         sprintf(mod_rev, "%04u-%02u-%02u", ((rev & LYB_REV_YEAR_MASK) >> LYB_REV_YEAR_SHIFT) + LYB_REV_YEAR_OFFSET,
                 (rev & LYB_REV_MONTH_MASK) >> LYB_REV_MONTH_SHIFT, rev & LYB_REV_DAY_MASK);
-        mod = ly_ctx_get_module(lybctx->ctx, mod_name, mod_rev);
-        if ((parse_options & LYD_PARSE_LYB_MOD_UPDATE) && !mod) {
+    }
+
+    return LY_SUCCESS;
+}
+
+/**
+ * @brief Parse YANG model info.
+ *
+ * @param[in] lybctx LYB context.
+ * @param[in] parse_options Flag with options for parsing.
+ * @param[out] mod Parsed module.
+ * @return LY_ERR value.
+ */
+static LY_ERR
+lyb_parse_model(struct lylyb_ctx *lybctx, uint32_t parse_options, const struct lys_module **mod)
+{
+    LY_ERR ret = LY_SUCCESS;
+    const struct lys_module *m = NULL;
+    char *mod_name = NULL, mod_rev[LY_REV_SIZE];
+
+    /* read module info */
+    if ((ret = lyb_read_model(lybctx, &mod_name, mod_rev))) {
+        goto cleanup;
+    }
+
+    /* get the module */
+    if (mod_rev[0]) {
+        m = ly_ctx_get_module(lybctx->ctx, mod_name, mod_rev);
+        if ((parse_options & LYD_PARSE_LYB_MOD_UPDATE) && !m) {
             /* try to use an updated module */
-            mod = ly_ctx_get_module_implemented(lybctx->ctx, mod_name);
-            if (mod && (!mod->revision || (strcmp(mod->revision, mod_rev) < 0))) {
+            m = ly_ctx_get_module_implemented(lybctx->ctx, mod_name);
+            if (m && (!m->revision || (strcmp(m->revision, mod_rev) < 0))) {
                 /* not an implemented module in a newer revision */
-                mod = NULL;
+                m = NULL;
             }
         }
     } else {
-        mod = ly_ctx_get_module_latest(lybctx->ctx, mod_name);
+        m = ly_ctx_get_module_latest(lybctx->ctx, mod_name);
     }
-    /* TODO data_clb supported?
-    if (lybctx->ctx->data_clb) {
-        if (!*mod) {
-            *mod = lybctx->ctx->data_clb(lybctx->ctx, mod_name, NULL, 0, lybctx->ctx->data_clb_data);
-        } else if (!(*mod)->implemented) {
-            *mod = lybctx->ctx->data_clb(lybctx->ctx, mod_name, (*mod)->ns, LY_MODCLB_NOT_IMPLEMENTED, lybctx->ctx->data_clb_data);
-        }
-    }*/
 
-    if (!mod || !mod->implemented) {
+    if (!m || !m->implemented) {
         if (parse_options & LYD_PARSE_STRICT) {
-            if (!mod) {
+            if (!m) {
                 LOGERR(lybctx->ctx, LY_EINVAL, "Invalid context for LYB data parsing, missing module \"%s%s%s\".",
-                        mod_name, rev ? "@" : "", rev ? mod_rev : "");
-            } else if (!mod->implemented) {
+                        mod_name, mod_rev[0] ? "@" : "", mod_rev[0] ? mod_rev : "");
+            } else if (!m->implemented) {
                 LOGERR(lybctx->ctx, LY_EINVAL, "Invalid context for LYB data parsing, module \"%s%s%s\" not implemented.",
-                        mod_name, rev ? "@" : "", rev ? mod_rev : "");
+                        mod_name, mod_rev[0] ? "@" : "", mod_rev[0] ? mod_rev : "");
             }
             ret = LY_EINVAL;
             goto cleanup;
@@ -399,13 +419,13 @@
 
     }
 
-    if (mod) {
+    if (m) {
         /* fill cached hashes, if not already */
-        lyb_cache_module_hash(mod);
+        lyb_cache_module_hash(m);
     }
 
 cleanup:
-    *model = mod;
+    *mod = m;
     free(mod_name);
     return ret;
 }
@@ -748,7 +768,7 @@
             break;
         }
         /* skip schema nodes from models not present during printing */
-        if (lyb_has_schema_model(sibling, lybctx->lybctx->models) &&
+        if (((sibling->module->ctx != lybctx->lybctx->ctx) || lyb_has_schema_model(sibling, lybctx->lybctx->models)) &&
                 lyb_is_schema_hash_match((struct lysc_node *)sibling, hash, hash_count)) {
             /* match found */
             break;
@@ -776,6 +796,50 @@
 }
 
 /**
+ * @brief Parse schema node name of a nested extension data node.
+ *
+ * @param[in] lybctx LYB context.
+ * @param[in] parent Data parent.
+ * @param[in] mod_name Module name of the node.
+ * @param[out] snode Parsed found schema node of a nested extension.
+ * @return LY_ERR value.
+ */
+static LY_ERR
+lyb_parse_schema_nested_ext(struct lyd_lyb_ctx *lybctx, const struct lyd_node *parent, const char *mod_name,
+        const struct lysc_node **snode)
+{
+    LY_ERR rc = LY_SUCCESS, r;
+    char *name = NULL;
+    struct lysc_ext_instance *ext;
+
+    assert(parent);
+
+    /* read schema node name */
+    LY_CHECK_GOTO(rc = lyb_read_string(&name, sizeof(uint16_t), lybctx->lybctx), cleanup);
+
+    /* check for extension data */
+    r = ly_nested_ext_schema(parent, NULL, mod_name, mod_name ? strlen(mod_name) : 0, LY_VALUE_JSON, NULL, name,
+            strlen(name), snode, &ext);
+    if (r == LY_ENOT) {
+        /* failed to parse */
+        LOGERR(lybctx->lybctx->ctx, LY_EINVAL, "Failed to parse node \"%s\" as nested extension instance data.", name);
+        rc = LY_EINVAL;
+        goto cleanup;
+    } else if (r) {
+        /* error */
+        rc = r;
+        goto cleanup;
+    }
+
+    /* fill cached hashes in the module, it may be from a different context */
+    lyb_cache_module_hash((*snode)->module);
+
+cleanup:
+    free(name);
+    return rc;
+}
+
+/**
  * @brief Read until the end of the current siblings.
  *
  * @param[in] lybctx LYB context.
@@ -849,7 +913,11 @@
         struct ly_set *parsed)
 {
     /* insert, keep first pointer correct */
-    lyd_insert_node(parent, first_p, node, lybctx->parse_opts & LYD_PARSE_ORDERED ? 1 : 0);
+    if (parent && (LYD_CTX(parent) != LYD_CTX(node))) {
+        lyd_insert_ext(parent, node);
+    } else {
+        lyd_insert_node(parent, first_p, node, lybctx->parse_opts & LYD_PARSE_ORDERED ? 1 : 0);
+    }
     while (!parent && (*first_p)->prev->next) {
         *first_p = (*first_p)->prev;
     }
@@ -1363,12 +1431,12 @@
 }
 
 /**
- * @brief Parse node.
+ * @brief Parse a node.
  *
- * @param[in] out Out structure.
- * @param[in,out] printed_node Current data node to print. Sets to the last printed node.
- * @param[in,out] sibling_ht Cached hash table for these siblings, created if NULL.
  * @param[in] lybctx LYB context.
+ * @param[in] parent Data parent of the sibling, must be set if @p first_p is not.
+ * @param[in,out] first_p First top-level sibling, must be set if @p parent is not.
+ * @param[in,out] parsed Set of all successfully parsed nodes to add to.
  * @return LY_ERR value.
  */
 static LY_ERR
@@ -1378,19 +1446,33 @@
     LY_ERR ret;
     const struct lysc_node *snode;
     const struct lys_module *mod;
+    enum lylyb_node_type lyb_type;
+    char *mod_name = NULL, mod_rev[LY_REV_SIZE];
 
-    if (!parent || !parent->schema) {
-        /* top-level or opaque, read module name */
-        ret = lyb_parse_model(lybctx->lybctx, lybctx->parse_opts, &mod);
-        LY_CHECK_RET(ret);
+    /* read node type */
+    lyb_read_number(&lyb_type, sizeof lyb_type, 1, lybctx->lybctx);
+
+    switch (lyb_type) {
+    case LYB_NODE_TOP:
+        /* top-level, read module name */
+        LY_CHECK_GOTO(ret = lyb_parse_model(lybctx->lybctx, lybctx->parse_opts, &mod), cleanup);
 
         /* read hash, find the schema node starting from mod */
-        ret = lyb_parse_schema_hash(lybctx, NULL, mod, &snode);
-    } else {
-        /* read hash, find the schema node starting from parent schema */
-        ret = lyb_parse_schema_hash(lybctx, parent->schema, NULL, &snode);
+        LY_CHECK_GOTO(ret = lyb_parse_schema_hash(lybctx, NULL, mod, &snode), cleanup);
+        break;
+    case LYB_NODE_CHILD:
+    case LYB_NODE_OPAQ:
+        /* read hash, find the schema node starting from parent schema, if any */
+        LY_CHECK_GOTO(ret = lyb_parse_schema_hash(lybctx, parent ? parent->schema : NULL, NULL, &snode), cleanup);
+        break;
+    case LYB_NODE_EXT:
+        /* ext, read module name */
+        LY_CHECK_GOTO(ret = lyb_read_model(lybctx->lybctx, &mod_name, mod_rev), cleanup);
+
+        /* read schema node name, find the nexted ext schema node */
+        LY_CHECK_GOTO(ret = lyb_parse_schema_nested_ext(lybctx, parent, mod_name, &snode), cleanup);
+        break;
     }
-    LY_CHECK_RET(ret);
 
     if (!snode) {
         ret = lyb_parse_node_opaq(lybctx, parent, first_p, parsed);
@@ -1405,8 +1487,10 @@
     } else {
         ret = lyb_parse_node_leaf(lybctx, parent, snode, first_p, parsed);
     }
-    LY_CHECK_RET(ret);
+    LY_CHECK_GOTO(ret, cleanup);
 
+cleanup:
+    free(mod_name);
     return ret;
 }
 
@@ -1423,18 +1507,15 @@
 lyb_parse_siblings(struct lyd_lyb_ctx *lybctx, struct lyd_node *parent, struct lyd_node **first_p,
         struct ly_set *parsed)
 {
-    LY_ERR ret;
     ly_bool top_level;
 
     top_level = !LY_ARRAY_COUNT(lybctx->lybctx->siblings);
 
     /* register a new siblings */
-    ret = lyb_read_start_siblings(lybctx->lybctx);
-    LY_CHECK_RET(ret);
+    LY_CHECK_RET(lyb_read_start_siblings(lybctx->lybctx));
 
     while (LYB_LAST_SIBLING(lybctx->lybctx).written) {
-        ret = lyb_parse_node(lybctx, parent, first_p, parsed);
-        LY_CHECK_RET(ret);
+        LY_CHECK_RET(lyb_parse_node(lybctx, parent, first_p, parsed));
 
         if (top_level && !(lybctx->int_opts & LYD_INTOPT_WITH_SIBLINGS)) {
             break;
@@ -1442,10 +1523,9 @@
     }
 
     /* end the siblings */
-    ret = lyb_read_stop_siblings(lybctx->lybctx);
-    LY_CHECK_RET(ret);
+    LY_CHECK_RET(lyb_read_stop_siblings(lybctx->lybctx));
 
-    return ret;
+    return LY_SUCCESS;
 }
 
 /**
diff --git a/src/parser_xml.c b/src/parser_xml.c
index cb237f5..1f395b8 100644
--- a/src/parser_xml.c
+++ b/src/parser_xml.c
@@ -1,9 +1,10 @@
 /**
  * @file parser_xml.c
  * @author Radek Krejci <rkrejci@cesnet.cz>
+ * @author Michal Vasko <mvasko@cesnet.cz>
  * @brief XML data parser for libyang
  *
- * Copyright (c) 2019 CESNET, z.s.p.o.
+ * Copyright (c) 2019 - 2022 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.
@@ -410,179 +411,150 @@
 }
 
 /**
- * @brief Try to parse data with a parent based on an extension instance.
+ * @brief Get sensible data hints for an opaque node.
  *
- * @param[in] lydctx XML data parser context.
- * @param[in,out] parent Parent node where the children are inserted.
- * @return LY_SUCCESS on success;
- * @return LY_ENOT if no extension instance parsed the data;
- * @return LY_ERR on error.
+ * @param[in] name Node name.
+ * @param[in] name_len Length of @p name.
+ * @param[in] value Node value.
+ * @param[in] value_len Length of @p value.
+ * @param[in] first Node first sibling.
+ * @param[in] ns Node module namespace.
+ * @param[out] hints Data hints to use.
+ * @param[out] anchor Anchor to insert after in case of a list.
  */
-static LY_ERR
-lydxml_nested_ext(struct lyd_xml_ctx *lydctx, struct lyd_node *parent)
+static void
+lydxml_get_hints_opaq(const char *name, size_t name_len, const char *value, size_t value_len, struct lyd_node *first,
+        const char *ns, uint32_t *hints, struct lyd_node **anchor)
 {
-    LY_ERR r;
-    struct ly_in in_bck, in_start, in_ext;
-    LY_ARRAY_COUNT_TYPE u;
-    struct lysc_ext_instance *nested_exts = NULL;
-    lyplg_ext_data_parse_clb ext_parse_cb;
-    struct lyd_ctx_ext_val *ext_val;
+    struct lyd_node_opaq *opaq;
+    char *ptr;
+    long num;
 
-    /* backup current input */
-    in_bck = *lydctx->xmlctx->in;
+    *hints = 0;
+    *anchor = NULL;
 
-    /* go back in the input for extension parsing */
-    in_start = *lydctx->xmlctx->in;
-    if (lydctx->xmlctx->status != LYXML_ELEM_CONTENT) {
-        assert((lydctx->xmlctx->status == LYXML_ELEMENT) || (lydctx->xmlctx->status == LYXML_ATTRIBUTE));
-        in_start.current = lydctx->xmlctx->prefix ? lydctx->xmlctx->prefix : lydctx->xmlctx->name;
-    }
-    do {
-        --in_start.current;
-    } while (in_start.current[0] != '<');
-
-    /* check if there are any nested extension instances */
-    if (parent && parent->schema) {
-        nested_exts = parent->schema->exts;
-    }
-    LY_ARRAY_FOR(nested_exts, u) {
-        /* prepare the input and try to parse this extension data */
-        in_ext = in_start;
-        ext_parse_cb = nested_exts[u].def->plugin->parse;
-        r = ext_parse_cb(&in_ext, LYD_XML, &nested_exts[u], parent, lydctx->parse_opts | LYD_PARSE_ONLY);
-        if (!r) {
-            /* data successfully parsed, remember for validation */
-            if (!(lydctx->parse_opts & LYD_PARSE_ONLY)) {
-                ext_val = malloc(sizeof *ext_val);
-                LY_CHECK_ERR_RET(!ext_val, LOGMEM(lydctx->xmlctx->ctx), LY_EMEM);
-                ext_val->ext = &nested_exts[u];
-                ext_val->sibling = lyd_child_no_keys(parent);
-                LY_CHECK_RET(ly_set_add(&lydctx->ext_val, ext_val, 1, NULL));
+    if (!value_len) {
+        /* no value */
+        *hints |= LYD_VALHINT_EMPTY;
+    } else if (!strncmp(value, "true", value_len) || !strncmp(value, "false", value_len)) {
+        /* boolean value */
+        *hints |= LYD_VALHINT_BOOLEAN;
+    } else {
+        num = strtol(value, &ptr, 10);
+        if ((unsigned)(ptr - value) == value_len) {
+            /* number value */
+            *hints |= LYD_VALHINT_DECNUM;
+            if ((num < INT32_MIN) || (num > UINT32_MAX)) {
+                /* large number */
+                *hints |= LYD_VALHINT_NUM64;
             }
-
-            /* adjust the xmlctx accordingly */
-            *lydctx->xmlctx->in = in_ext;
-            lydctx->xmlctx->status = LYXML_ELEM_CONTENT;
-            lydctx->xmlctx->dynamic = 0;
-            ly_set_rm_index(&lydctx->xmlctx->elements, lydctx->xmlctx->elements.count - 1, free);
-            lyxml_ns_rm(lydctx->xmlctx);
-            LY_CHECK_RET(lyxml_ctx_next(lydctx->xmlctx));
-            return LY_SUCCESS;
-        } else if (r != LY_ENOT) {
-            /* fatal error */
-            return r;
+        } else {
+            /* string value */
+            *hints |= LYD_VALHINT_STRING;
         }
-        /* data was not from this module, continue */
     }
 
-    /* no extensions or none matched, restore input */
-    *lydctx->xmlctx->in = in_bck;
-    return LY_ENOT;
+    if (!first) {
+        return;
+    }
+
+    /* search backwards to find the last instance */
+    do {
+        first = first->prev;
+        if (first->schema) {
+            continue;
+        }
+
+        opaq = (struct lyd_node_opaq *)first;
+        assert(opaq->format == LY_VALUE_XML);
+        if (!ly_strncmp(opaq->name.name, name, name_len) && !strcmp(opaq->name.module_ns, ns)) {
+            if (opaq->value && opaq->value[0]) {
+                /* leaf-list nodes */
+                opaq->hints |= LYD_NODEHINT_LEAFLIST;
+                *hints |= LYD_NODEHINT_LEAFLIST;
+            } else {
+                /* list nodes */
+                opaq->hints |= LYD_NODEHINT_LIST;
+                *hints |= LYD_NODEHINT_LIST;
+            }
+            *anchor = first;
+            break;
+        }
+    } while (first->prev->next);
 }
 
 /**
- * @brief Parse XML subtree.
+ * @brief Get schema node for the current element.
  *
- * @param[in] lydctx XML YANG data parser context.
- * @param[in,out] parent Parent node where the children are inserted. NULL in case of parsing top-level elements.
- * @param[in,out] first_p Pointer to the first (@p parent or top-level) child. In case there were already some siblings,
- * this may point to a previously existing node.
- * @param[in,out] parsed Optional set to add all the parsed siblings into.
- * @return LY_ERR value.
+ * @param[in] lydctx XML data parser context.
+ * @param[in] parent Parsed parent data node, if any.
+ * @param[in] prefix Element prefix, if any.
+ * @param[in] prefix_len Length of @p prefix.
+ * @param[in] name Element name.
+ * @param[in] name_len Length of @p name.
+ * @param[out] snode Found schema node, NULL if no suitable was found.
+ * @param[out] ext Extension instance that provided @p snode, if any.
+ * @return LY_SUCCESS on success;
+ * @return LY_ERR on error.
  */
 static LY_ERR
-lydxml_subtree_r(struct lyd_xml_ctx *lydctx, struct lyd_node *parent, struct lyd_node **first_p, struct ly_set *parsed)
+lydxml_subtree_snode(struct lyd_xml_ctx *lydctx, const struct lyd_node *parent, const char *prefix, size_t prefix_len,
+        const char *name, size_t name_len, const struct lysc_node **snode, struct lysc_ext_instance **ext)
 {
-    LY_ERR ret = LY_SUCCESS, r;
-    const char *prefix, *name;
-    size_t prefix_len, name_len;
+    LY_ERR r;
     struct lyxml_ctx *xmlctx;
     const struct ly_ctx *ctx;
     const struct lyxml_ns *ns;
-    struct lyd_meta *meta = NULL;
-    struct lyd_attr *attr = NULL;
-    const struct lysc_node *snode;
     struct lys_module *mod;
-    uint32_t prev_parse_opts, prev_int_opts;
-    struct lyd_node *node = NULL, *anchor;
-    void *val_prefix_data = NULL;
-    LY_VALUE_FORMAT format;
     uint32_t getnext_opts;
-    ly_bool parse_subtree;
-    char *val;
-
-    assert(parent || first_p);
 
     xmlctx = lydctx->xmlctx;
     ctx = xmlctx->ctx;
     getnext_opts = lydctx->int_opts & LYD_INTOPT_REPLY ? LYS_GETNEXT_OUTPUT : 0;
 
-    parse_subtree = lydctx->parse_opts & LYD_PARSE_SUBTREE ? 1 : 0;
-    /* all descendants should be parsed */
-    lydctx->parse_opts &= ~LYD_PARSE_SUBTREE;
+    *snode = NULL;
+    *ext = NULL;
 
-    assert(xmlctx->status == LYXML_ELEMENT);
-
-    /* remember element prefix and name */
-    prefix = xmlctx->prefix;
-    prefix_len = xmlctx->prefix_len;
-    name = xmlctx->name;
-    name_len = xmlctx->name_len;
-
-    /* get the element module */
+    /* get current namespace */
     ns = lyxml_ns_get(&xmlctx->ns, prefix, prefix_len);
     if (!ns) {
         LOGVAL(ctx, LYVE_REFERENCE, "Unknown XML prefix \"%.*s\".", (int)prefix_len, prefix);
-        ret = LY_EVALID;
-        goto error;
+        return LY_EVALID;
     }
-    mod = ly_ctx_get_module_implemented_ns(ctx, ns->uri);
+
+    /* get the element module, use parent context if possible because of extensions */
+    mod = ly_ctx_get_module_implemented_ns(parent ? LYD_CTX(parent) : ctx, ns->uri);
     if (!mod) {
         /* check for extension data */
-        r = lydxml_nested_ext(lydctx, parent);
-        if (!r) {
-            /* successfully parsed */
+        r = ly_nested_ext_schema(parent, NULL, prefix, prefix_len, LY_VALUE_XML, &lydctx->xmlctx->ns, name, name_len,
+                snode, ext);
+        if (r != LY_ENOT) {
+            /* success or error */
             return r;
-        } else if (r != LY_ENOT) {
-            /* error */
-            ret = r;
-            goto error;
         }
 
         /* unknown module */
         if (lydctx->parse_opts & LYD_PARSE_STRICT) {
             LOGVAL(ctx, LYVE_REFERENCE, "No module with namespace \"%s\" in the context.", ns->uri);
-            ret = LY_EVALID;
-            goto error;
+            return LY_EVALID;
         }
-        if (!(lydctx->parse_opts & LYD_PARSE_OPAQ)) {
-            /* skip element with children */
-            LY_CHECK_GOTO(ret = lydxml_data_skip(xmlctx), error);
-            return LY_SUCCESS;
-        }
+        return LY_SUCCESS;
     }
 
-    /* parser next */
-    LY_CHECK_GOTO(ret = lyxml_ctx_next(xmlctx), error);
-
     /* get the schema node */
-    snode = NULL;
     if (mod) {
         if (!parent && lydctx->ext) {
-            snode = lysc_ext_find_node(lydctx->ext, mod, name, name_len, 0, getnext_opts);
+            *snode = lysc_ext_find_node(lydctx->ext, mod, name, name_len, 0, getnext_opts);
         } else {
-            snode = lys_find_child(parent ? parent->schema : NULL, mod, name, name_len, 0, getnext_opts);
+            *snode = lys_find_child(parent ? parent->schema : NULL, mod, name, name_len, 0, getnext_opts);
         }
-        if (!snode) {
+        if (!*snode) {
             /* check for extension data */
-            r = lydxml_nested_ext(lydctx, parent);
-            if (!r) {
-                /* successfully parsed */
+            r = ly_nested_ext_schema(parent, NULL, prefix, prefix_len, LY_VALUE_XML, &lydctx->xmlctx->ns, name,
+                    name_len, snode, ext);
+            if (r != LY_ENOT) {
+                /* success or error */
                 return r;
-            } else if (r != LY_ENOT) {
-                /* error */
-                ret = r;
-                goto error;
             }
 
             /* unknown data node */
@@ -602,22 +574,81 @@
                     LOGVAL(ctx, LYVE_REFERENCE, "Node \"%.*s\" not found in the \"%s\" module.",
                             (int)name_len, name, mod->name);
                 }
-                ret = LY_EVALID;
-                goto error;
-            } else if (!(lydctx->parse_opts & LYD_PARSE_OPAQ)) {
-                LOGVRB("Skipping parsing of unknown node \"%.*s\".", name_len, name);
-
-                /* skip element with children */
-                LY_CHECK_GOTO(ret = lydxml_data_skip(xmlctx), error);
-                return LY_SUCCESS;
+                return LY_EVALID;
             }
+            return LY_SUCCESS;
         } else {
             /* check that schema node is valid and can be used */
-            LY_CHECK_GOTO(ret = lyd_parser_check_schema((struct lyd_ctx *)lydctx, snode), error);
-            LY_CHECK_GOTO(ret = lydxml_data_check_opaq(lydctx, &snode), error);
+            LY_CHECK_RET(lyd_parser_check_schema((struct lyd_ctx *)lydctx, *snode));
+            LY_CHECK_RET(lydxml_data_check_opaq(lydctx, snode));
         }
     }
 
+    return LY_SUCCESS;
+}
+
+/**
+ * @brief Parse XML subtree.
+ *
+ * @param[in] lydctx XML YANG data parser context.
+ * @param[in,out] parent Parent node where the children are inserted. NULL in case of parsing top-level elements.
+ * @param[in,out] first_p Pointer to the first (@p parent or top-level) child. In case there were already some siblings,
+ * this may point to a previously existing node.
+ * @param[in,out] parsed Optional set to add all the parsed siblings into.
+ * @return LY_ERR value.
+ */
+static LY_ERR
+lydxml_subtree_r(struct lyd_xml_ctx *lydctx, struct lyd_node *parent, struct lyd_node **first_p, struct ly_set *parsed)
+{
+    LY_ERR ret = LY_SUCCESS;
+    const char *prefix, *name;
+    size_t prefix_len, name_len;
+    struct lyxml_ctx *xmlctx;
+    const struct ly_ctx *ctx;
+    const struct lyxml_ns *ns;
+    struct lyd_meta *meta = NULL;
+    struct lyd_attr *attr = NULL;
+    const struct lysc_node *snode;
+    struct lysc_ext_instance *ext;
+    uint32_t prev_parse_opts, orig_parse_opts, prev_int_opts, hints;
+    struct lyd_node *node = NULL, *anchor, *insert_anchor = NULL;
+    void *val_prefix_data = NULL;
+    LY_VALUE_FORMAT format;
+    ly_bool parse_subtree;
+    char *val;
+
+    assert(parent || first_p);
+
+    xmlctx = lydctx->xmlctx;
+    ctx = xmlctx->ctx;
+
+    parse_subtree = lydctx->parse_opts & LYD_PARSE_SUBTREE ? 1 : 0;
+    /* all descendants should be parsed */
+    lydctx->parse_opts &= ~LYD_PARSE_SUBTREE;
+    orig_parse_opts = lydctx->parse_opts;
+
+    assert(xmlctx->status == LYXML_ELEMENT);
+
+    /* remember element prefix and name */
+    prefix = xmlctx->prefix;
+    prefix_len = xmlctx->prefix_len;
+    name = xmlctx->name;
+    name_len = xmlctx->name_len;
+
+    /* parser next */
+    LY_CHECK_GOTO(ret = lyxml_ctx_next(xmlctx), error);
+
+    /* get the schema node */
+    LY_CHECK_GOTO(ret = lydxml_subtree_snode(lydctx, parent, prefix, prefix_len, name, name_len, &snode, &ext), error);
+
+    if (!snode && !(lydctx->parse_opts & LYD_PARSE_OPAQ)) {
+        LOGVRB("Skipping parsing of unknown node \"%.*s\".", name_len, name);
+
+        /* skip element with children */
+        LY_CHECK_GOTO(ret = lydxml_data_skip(xmlctx), error);
+        return LY_SUCCESS;
+    }
+
     /* create metadata/attributes */
     if (xmlctx->status == LYXML_ATTRIBUTE) {
         if (snode) {
@@ -637,7 +668,7 @@
         if (xmlctx->ws_only) {
             /* ignore WS-only value */
             if (xmlctx->dynamic) {
-                free((char *) xmlctx->value);
+                free((char *)xmlctx->value);
             }
             xmlctx->dynamic = 0;
             xmlctx->value = "";
@@ -654,9 +685,13 @@
         ns = lyxml_ns_get(&xmlctx->ns, prefix, prefix_len);
         assert(ns);
 
+        /* get best-effort node hints */
+        lydxml_get_hints_opaq(name, name_len, xmlctx->value, xmlctx->value_len, parent ? lyd_child(parent) : *first_p,
+                ns->uri, &hints, &insert_anchor);
+
         /* create node */
         ret = lyd_create_opaq(ctx, name, name_len, prefix, prefix_len, ns->uri, strlen(ns->uri), xmlctx->value,
-                xmlctx->value_len, &xmlctx->dynamic, format, val_prefix_data, LYD_HINT_DATA, &node);
+                xmlctx->value_len, &xmlctx->dynamic, format, val_prefix_data, hints, &node);
         LY_CHECK_GOTO(ret, error);
 
         /* parser next */
@@ -715,12 +750,21 @@
         /* parser next */
         LY_CHECK_GOTO(ret = lyxml_ctx_next(xmlctx), error);
 
+        prev_parse_opts = lydctx->parse_opts;
+        if (ext) {
+            /* only parse these extension data and validate afterwards */
+            lydctx->parse_opts |= LYD_PARSE_ONLY;
+        }
+
         /* process children */
         while (xmlctx->status == LYXML_ELEMENT) {
             ret = lydxml_subtree_r(lydctx, node, lyd_node_child_p(node), NULL);
             LY_CHECK_GOTO(ret, error);
         }
 
+        /* restore options */
+        lydctx->parse_opts = prev_parse_opts;
+
         if (snode->nodetype == LYS_LIST) {
             /* check all keys exist */
             LY_CHECK_GOTO(ret = lyd_parse_check_keys(node), error);
@@ -756,7 +800,7 @@
             LY_CHECK_ERR_GOTO(!val, LOGMEM(xmlctx->ctx); ret = LY_EMEM, error);
 
             /* parser next */
-            LY_CHECK_GOTO(ret = lyxml_ctx_next(xmlctx), error);
+            LY_CHECK_ERR_GOTO(ret = lyxml_ctx_next(xmlctx), free(val), error);
 
             /* create node */
             ret = lyd_create_any(snode, val, LYD_ANYDATA_STRING, 1, &node);
@@ -768,7 +812,7 @@
             /* update options so that generic data can be parsed */
             prev_parse_opts = lydctx->parse_opts;
             lydctx->parse_opts &= ~LYD_PARSE_STRICT;
-            lydctx->parse_opts |= LYD_PARSE_OPAQ;
+            lydctx->parse_opts |= LYD_PARSE_OPAQ | (ext ? LYD_PARSE_ONLY : 0);
             prev_int_opts = lydctx->int_opts;
             lydctx->int_opts |= LYD_INTOPT_ANY | LYD_INTOPT_WITH_SIBLINGS;
 
@@ -777,6 +821,7 @@
             while (xmlctx->status == LYXML_ELEMENT) {
                 ret = lydxml_subtree_r(lydctx, NULL, &anchor, NULL);
                 if (ret) {
+                    lyd_free_siblings(anchor);
                     break;
                 }
             }
@@ -796,7 +841,7 @@
 
     /* add/correct flags */
     if (snode) {
-        lyd_parse_set_data_flags(node, &lydctx->node_when, &meta, lydctx->parse_opts);
+        LY_CHECK_GOTO(ret = lyd_parse_set_data_flags(node, &meta, (struct lyd_ctx *)lydctx, ext), error);
     }
 
     /* parser next */
@@ -813,7 +858,13 @@
     }
 
     /* insert, keep first pointer correct */
-    lyd_insert_node(parent, first_p, node, lydctx->parse_opts & LYD_PARSE_ORDERED ? 1 : 0);
+    if (insert_anchor) {
+        lyd_insert_after(insert_anchor, node);
+    } else if (ext) {
+        LY_CHECK_GOTO(ret = lyd_insert_ext(parent, node), error);
+    } else {
+        lyd_insert_node(parent, first_p, node, lydctx->parse_opts & LYD_PARSE_ORDERED ? 1 : 0);
+    }
     while (!parent && (*first_p)->prev->next) {
         *first_p = (*first_p)->prev;
     }
@@ -823,10 +874,12 @@
         ly_set_add(parsed, node, 1, NULL);
     }
 
+    lydctx->parse_opts = orig_parse_opts;
     LOG_LOCBACK(node ? 1 : 0, node ? 1 : 0, 0, 0);
     return LY_SUCCESS;
 
 error:
+    lydctx->parse_opts = orig_parse_opts;
     LOG_LOCBACK(node ? 1 : 0, node ? 1 : 0, 0, 0);
     lyd_free_meta_siblings(meta);
     lyd_free_attr_siblings(ctx, attr);
diff --git a/src/path.c b/src/path.c
index 932a039..f53768b 100644
--- a/src/path.c
+++ b/src/path.c
@@ -374,33 +374,42 @@
 }
 
 /**
- * @brief Parse prefix from a NameTest, if any, and node name, and return expected module of the node.
+ * @brief Parse NameTest and get the corresponding schema node.
  *
  * @param[in] ctx libyang context.
  * @param[in] cur_node Optional current (original context) node.
  * @param[in] cur_mod Current module of the path (where the path is "instantiated"). Needed for ::LY_VALUE_SCHEMA
  * and ::LY_VALUE_SCHEMA_RESOLVED.
- * @param[in] prev_ctx_node Previous context node. Needed for ::LY_VALUE_JSON.
+ * @param[in] prev_ctx_node Previous context node.
  * @param[in] expr Parsed path.
  * @param[in] tok_idx Index in @p expr.
  * @param[in] format Format of the path.
  * @param[in] prefix_data Format-specific data for resolving any prefixes (see ::ly_resolve_prefix).
- * @param[out] mod Resolved module.
- * @param[out] name Parsed node name.
- * @param[out] name_len Length of @p name.
+ * @param[in] top_ext Optional top-level extension to use for searching the schema node.
+ * @param[in] getnext_opts Options to be used for ::lys_getnext() calls.
+ * @param[out] snode Resolved schema node.
+ * @param[out] ext Optional extension instance of @p snode, if any.
  * @return LY_ERR value.
  */
 static LY_ERR
-ly_path_compile_prefix(const struct ly_ctx *ctx, const struct lysc_node *cur_node, const struct lys_module *cur_mod,
+ly_path_compile_snode(const struct ly_ctx *ctx, const struct lysc_node *cur_node, const struct lys_module *cur_mod,
         const struct lysc_node *prev_ctx_node, const struct lyxp_expr *expr, uint16_t tok_idx, LY_VALUE_FORMAT format,
-        void *prefix_data, const struct lys_module **mod, const char **name, size_t *name_len)
+        void *prefix_data, const struct lysc_ext_instance *top_ext, uint32_t getnext_opts, const struct lysc_node **snode,
+        struct lysc_ext_instance **ext)
 {
     LY_ERR ret;
-    const char *pref;
-    size_t len;
+    const struct lys_module *mod = NULL;
+    struct lysc_ext_instance *e = NULL;
+    const char *pref, *name;
+    size_t len, name_len;
 
     assert(expr->tokens[tok_idx] == LYXP_TOKEN_NAMETEST);
 
+    *snode = NULL;
+    if (ext) {
+        *ext = NULL;
+    }
+
     /* get prefix */
     if ((pref = strnstr(expr->expr + expr->tok_pos[tok_idx], ":", expr->tok_len[tok_idx]))) {
         len = pref - (expr->expr + expr->tok_pos[tok_idx]);
@@ -409,18 +418,37 @@
         len = 0;
     }
 
-    /* find next node module */
+    /* set name */
+    if (pref) {
+        name = pref + len + 1;
+        name_len = expr->tok_len[tok_idx] - len - 1;
+    } else {
+        name = expr->expr + expr->tok_pos[tok_idx];
+        name_len = expr->tok_len[tok_idx];
+    }
+
+    /* find node module */
     if (pref) {
         LOG_LOCSET(cur_node, NULL, NULL, NULL);
 
-        *mod = ly_resolve_prefix(ctx, pref, len, format, prefix_data);
-        if (!*mod) {
+        mod = ly_resolve_prefix(ctx, pref, len, format, prefix_data);
+        if ((!mod || !mod->implemented) && prev_ctx_node) {
+            /* check for nested ext data */
+            ret = ly_nested_ext_schema(NULL, prev_ctx_node, pref, len, format, prefix_data, name, name_len, snode, &e);
+            if (!ret) {
+                goto success;
+            } else if (ret != LY_ENOT) {
+                goto error;
+            }
+        }
+
+        if (!mod) {
             LOGVAL(ctx, LYVE_XPATH, "No module connected with the prefix \"%.*s\" found (prefix format %s).",
                     (int)len, pref, ly_format2str(format));
             ret = LY_EVALID;
             goto error;
-        } else if (!(*mod)->implemented) {
-            LOGVAL(ctx, LYVE_XPATH, "Not implemented module \"%s\" in path.", (*mod)->name);
+        } else if (!mod->implemented) {
+            LOGVAL(ctx, LYVE_XPATH, "Not implemented module \"%s\" in path.", mod->name);
             ret = LY_EVALID;
             goto error;
         }
@@ -434,7 +462,7 @@
                 LOGINT_RET(ctx);
             }
             /* use current module */
-            *mod = cur_mod;
+            mod = cur_mod;
             break;
         case LY_VALUE_JSON:
         case LY_VALUE_LYB:
@@ -442,7 +470,7 @@
                 LOGINT_RET(ctx);
             }
             /* inherit module of the previous node */
-            *mod = prev_ctx_node->module;
+            mod = prev_ctx_node->module;
             break;
         case LY_VALUE_CANON:
         case LY_VALUE_XML:
@@ -452,15 +480,25 @@
         }
     }
 
-    /* set name */
-    if (pref) {
-        *name = pref + len + 1;
-        *name_len = expr->tok_len[tok_idx] - len - 1;
+    /* find schema node */
+    if (!prev_ctx_node && top_ext) {
+        *snode = lysc_ext_find_node(top_ext, mod, name, name_len, 0, getnext_opts);
     } else {
-        *name = expr->expr + expr->tok_pos[tok_idx];
-        *name_len = expr->tok_len[tok_idx];
+        *snode = lys_find_child(prev_ctx_node, mod, name, name_len, 0, getnext_opts);
+        if (!(*snode) && prev_ctx_node) {
+            ret = ly_nested_ext_schema(NULL, prev_ctx_node, pref, len, format, prefix_data, name, name_len, snode, &e);
+            LY_CHECK_RET(ret && (ret != LY_ENOT), ret);
+        }
+    }
+    if (!(*snode)) {
+        LOGVAL(ctx, LYVE_XPATH, "Not found node \"%.*s\" in path.", (int)name_len, name);
+        return LY_ENOTFOUND;
     }
 
+success:
+    if (ext) {
+        *ext = e;
+    }
     return LY_SUCCESS;
 
 error:
@@ -476,9 +514,8 @@
     LY_ERR ret = LY_SUCCESS;
     struct ly_path_predicate *p;
     const struct lysc_node *key;
-    const struct lys_module *mod = NULL;
-    const char *name, *val;
-    size_t name_len, val_len, key_count;
+    const char *val;
+    size_t val_len, key_count;
 
     assert(ctx && ctx_node);
 
@@ -506,14 +543,9 @@
 
         do {
             /* NameTest, find the key */
-            LY_CHECK_RET(ly_path_compile_prefix(ctx, cur_node, cur_mod, ctx_node, expr, *tok_idx, format, prefix_data,
-                    &mod, &name, &name_len));
-            key = lys_find_child(ctx_node, mod, name, name_len, 0, 0);
-            if (!key) {
-                LOGVAL(ctx, LYVE_XPATH, "Not found node \"%.*s\" in path.", (int)name_len, name);
-                ret = LY_ENOTFOUND;
-                goto cleanup;
-            } else if ((key->nodetype != LYS_LEAF) || !(key->flags & LYS_KEY)) {
+            LY_CHECK_RET(ly_path_compile_snode(ctx, cur_node, cur_mod, ctx_node, expr, *tok_idx, format, prefix_data,
+                    NULL, 0, &key, NULL));
+            if ((key->nodetype != LYS_LEAF) || !(key->flags & LYS_KEY)) {
                 LOGVAL(ctx, LYVE_XPATH, "Key expected instead of %s \"%s\" in path.", lys_nodetype2str(key->nodetype),
                         key->name);
                 ret = LY_EVALID;
@@ -638,7 +670,7 @@
         LY_ARRAY_NEW_GOTO(ctx, *predicates, p, ret, cleanup);
 
         /* syntax was already checked */
-        p->position = strtoull(expr->expr + expr->tok_pos[*tok_idx], (char **)&name, LY_BASE_DEC);
+        p->position = strtoull(expr->expr + expr->tok_pos[*tok_idx], (char **)&val, LY_BASE_DEC);
         ++(*tok_idx);
 
         /* ']' */
@@ -668,9 +700,6 @@
 {
     LY_ERR ret = LY_SUCCESS;
     const struct lysc_node *key, *node, *node2;
-    const struct lys_module *mod;
-    const char *name;
-    size_t name_len;
     struct ly_ctx *ctx = cur_node->module->ctx;
 
     LOG_LOCSET(cur_node, NULL, NULL, NULL);
@@ -694,15 +723,10 @@
 
     do {
         /* NameTest, find the key */
-        ret = ly_path_compile_prefix(ctx, cur_node, cur_node->module, ctx_node, expr, *tok_idx, format, prefix_data,
-                &mod, &name, &name_len);
+        ret = ly_path_compile_snode(ctx, cur_node, cur_node->module, ctx_node, expr, *tok_idx, format, prefix_data,
+                NULL, 0, &key, NULL);
         LY_CHECK_GOTO(ret, cleanup);
-        key = lys_find_child(ctx_node, mod, name, name_len, 0, 0);
-        if (!key) {
-            LOGVAL(ctx, LYVE_XPATH, "Not found node \"%.*s\" in path.", (int)name_len, name);
-            ret = LY_EVALID;
-            goto cleanup;
-        } else if ((key->nodetype != LYS_LEAF) || !(key->flags & LYS_KEY)) {
+        if ((key->nodetype != LYS_LEAF) || !(key->flags & LYS_KEY)) {
             LOGVAL(ctx, LYVE_XPATH, "Key expected instead of %s \"%s\" in path.",
                     lys_nodetype2str(key->nodetype), key->name);
             ret = LY_EVALID;
@@ -757,14 +781,8 @@
 
             /* NameTest */
             assert(expr->tokens[*tok_idx] == LYXP_TOKEN_NAMETEST);
-            LY_CHECK_RET(ly_path_compile_prefix(ctx, cur_node, cur_node->module, node, expr, *tok_idx, format,
-                    prefix_data, &mod, &name, &name_len));
-            node2 = lys_find_child(node, mod, name, name_len, 0, 0);
-            if (!node2) {
-                LOGVAL(ctx, LYVE_XPATH, "Not found node \"%.*s\" in path.", (int)name_len, name);
-                ret = LY_EVALID;
-                goto cleanup;
-            }
+            LY_CHECK_RET(ly_path_compile_snode(ctx, cur_node, cur_node->module, node, expr, *tok_idx, format,
+                    prefix_data, NULL, 0, &node2, NULL));
             node = node2;
             ++(*tok_idx);
         } while ((*tok_idx + 1 < expr->used) && (expr->tokens[*tok_idx + 1] == LYXP_TOKEN_NAMETEST));
@@ -789,7 +807,7 @@
 
 cleanup:
     LOG_LOCBACK(1, 0, 0, 0);
-    return ret;
+    return (ret == LY_ENOTFOUND) ? LY_EVALID : ret;
 }
 
 /**
@@ -799,7 +817,7 @@
  * @param[in] cur_mod Current module of the path (where it was "instantiated"), ignored of @p lref. Used for nodes
  * without a prefix for ::LY_VALUE_SCHEMA and ::LY_VALUE_SCHEMA_RESOLVED format.
  * @param[in] ctx_node Optional context node, mandatory of @p lref.
- * @param[in] ext Extension instance containing the definition of the data being created. It is used to find the top-level
+ * @param[in] top_ext Extension instance containing the definition of the data being created. It is used to find the top-level
  * node inside the extension instance instead of a module. Note that this is the case not only if the @p ctx_node is NULL,
  * but also if the relative path starting in @p ctx_node reaches the document root via double dots.
  * @param[in] expr Parsed path.
@@ -816,17 +834,15 @@
  */
 static LY_ERR
 _ly_path_compile(const struct ly_ctx *ctx, const struct lys_module *cur_mod, const struct lysc_node *ctx_node,
-        const struct lysc_ext_instance *ext, const struct lyxp_expr *expr, ly_bool lref, uint8_t oper, uint8_t target,
+        const struct lysc_ext_instance *top_ext, const struct lyxp_expr *expr, ly_bool lref, uint8_t oper, uint8_t target,
         ly_bool limit_access_tree, LY_VALUE_FORMAT format, void *prefix_data, struct ly_path **path)
 {
     LY_ERR ret = LY_SUCCESS;
     uint16_t tok_idx = 0;
-    const struct lys_module *mod = NULL;
     const struct lysc_node *node2, *cur_node, *op;
     struct ly_path *p = NULL;
+    struct lysc_ext_instance *ext = NULL;
     uint32_t getnext_opts;
-    const char *name;
-    size_t name_len;
 
     assert(ctx);
     assert(!lref || ctx_node);
@@ -895,19 +911,12 @@
         /* NameTest */
         LY_CHECK_ERR_GOTO(lyxp_check_token(ctx, expr, tok_idx, LYXP_TOKEN_NAMETEST), ret = LY_EVALID, cleanup);
 
-        /* get module and node name */
-        LY_CHECK_GOTO(ret = ly_path_compile_prefix(ctx, cur_node, cur_mod, ctx_node, expr, tok_idx, format, prefix_data,
-                &mod, &name, &name_len), cleanup);
+        /* get schema node */
+        LY_CHECK_GOTO(ret = ly_path_compile_snode(ctx, cur_node, cur_mod, ctx_node, expr, tok_idx, format, prefix_data,
+                top_ext, getnext_opts, &node2, &ext), cleanup);
         ++tok_idx;
-
-        /* find the next node */
-        if (!ctx_node && ext) {
-            node2 = lysc_ext_find_node(ext, mod, name, name_len, 0, getnext_opts);
-        } else {
-            node2 = lys_find_child(ctx_node, mod, name, name_len, 0, getnext_opts);
-        }
-        if (!node2 || (op && (node2->nodetype & (LYS_RPC | LYS_ACTION | LYS_NOTIF)) && (node2 != op))) {
-            LOGVAL(ctx, LYVE_XPATH, "Not found node \"%.*s\" in path.", (int)name_len, name);
+        if ((op && (node2->nodetype & (LYS_RPC | LYS_ACTION | LYS_NOTIF)) && (node2 != op))) {
+            LOGVAL(ctx, LYVE_XPATH, "Not found node \"%s\" in path.", node2->name);
             ret = LY_EVALID;
             goto cleanup;
         }
@@ -916,6 +925,7 @@
         /* new path segment */
         LY_ARRAY_NEW_GOTO(ctx, *path, p, ret, cleanup);
         p->node = ctx_node;
+        p->ext = ext;
 
         /* compile any predicates */
         if (lref) {
@@ -948,24 +958,24 @@
         *path = NULL;
     }
     LOG_LOCBACK(1, 0, 0, 0);
-    return ret;
+    return (ret == LY_ENOTFOUND) ? LY_EVALID : ret;
 }
 
 LY_ERR
 ly_path_compile(const struct ly_ctx *ctx, const struct lys_module *cur_mod, const struct lysc_node *ctx_node,
-        const struct lysc_ext_instance *ext, const struct lyxp_expr *expr, uint8_t oper, uint8_t target,
+        const struct lysc_ext_instance *top_ext, const struct lyxp_expr *expr, uint8_t oper, uint8_t target,
         ly_bool limit_access_tree, LY_VALUE_FORMAT format, void *prefix_data, struct ly_path **path)
 {
-    return _ly_path_compile(ctx, cur_mod, ctx_node, ext, expr, 0, oper, target, limit_access_tree, format, prefix_data,
-            path);
+    return _ly_path_compile(ctx, cur_mod, ctx_node, top_ext, expr, 0, oper, target, limit_access_tree, format,
+            prefix_data, path);
 }
 
 LY_ERR
-ly_path_compile_leafref(const struct ly_ctx *ctx, const struct lysc_node *ctx_node, const struct lysc_ext_instance *ext,
+ly_path_compile_leafref(const struct ly_ctx *ctx, const struct lysc_node *ctx_node, const struct lysc_ext_instance *top_ext,
         const struct lyxp_expr *expr, uint8_t oper, uint8_t target, LY_VALUE_FORMAT format, void *prefix_data,
         struct ly_path **path)
 {
-    return _ly_path_compile(ctx, ctx_node->module, ctx_node, ext, expr, 1, oper, target, 1, format, prefix_data, path);
+    return _ly_path_compile(ctx, ctx_node->module, ctx_node, top_ext, expr, 1, oper, target, 1, format, prefix_data, path);
 }
 
 LY_ERR
diff --git a/src/path.h b/src/path.h
index d3dca9e..c079274 100644
--- a/src/path.h
+++ b/src/path.h
@@ -58,8 +58,9 @@
     const struct lysc_node *node; /**< Schema node representing the path segment, first node has special meaning:
                                        - is a top-level node - path is absolute,
                                        - is inner node - path is relative */
-    struct ly_path_predicate *predicates;  /**< [Sized array](@ref sizedarrays) of the path segment's predicates */
-    enum ly_path_pred_type pred_type;   /**< Predicate type (see YANG ABNF) */
+    const struct lysc_ext_instance *ext;    /**< Extension instance of @p node, if any */
+    struct ly_path_predicate *predicates;   /**< [Sized array](@ref sizedarrays) of the path segment's predicates */
+    enum ly_path_pred_type pred_type;       /**< Predicate type (see YANG ABNF) */
 };
 
 /**
@@ -147,7 +148,7 @@
  * @param[in] cur_mod Current module of the path (where it was "instantiated"). Used for nodes in schema-nodeid
  * without a prefix for ::LY_VALUE_SCHEMA and ::LY_VALUE_SCHEMA_RESOLVED format.
  * @param[in] ctx_node Optional context node.
- * @param[in] ext Extension instance containing the definition of the data being created. It is used to find the top-level
+ * @param[in] top_ext Extension instance containing the definition of the data being created. It is used to find the top-level
  * node inside the extension instance instead of a module. Note that this is the case not only if the @p ctx_node is NULL,
  * but also if the relative path starting in @p ctx_node reaches the document root via double dots.
  * @param[in] expr Parsed path.
@@ -160,7 +161,7 @@
  * @return LY_ERR value.
  */
 LY_ERR ly_path_compile(const struct ly_ctx *ctx, const struct lys_module *cur_mod, const struct lysc_node *ctx_node,
-        const struct lysc_ext_instance *ext, const struct lyxp_expr *expr, uint8_t oper, uint8_t target,
+        const struct lysc_ext_instance *top_ext, const struct lyxp_expr *expr, uint8_t oper, uint8_t target,
         ly_bool limit_access_tree, LY_VALUE_FORMAT format, void *prefix_data, struct ly_path **path);
 
 /**
@@ -168,7 +169,7 @@
  *
  * @param[in] ctx libyang context.
  * @param[in] ctx_node Context node.
- * @param[in] ext Extension instance containing the definition of the data being created. It is used to find the top-level
+ * @param[in] top_ext Extension instance containing the definition of the data being created. It is used to find the top-level
  * node inside the extension instance instead of a module. Note that this is the case not only if the @p ctx_node is NULL,
  * but also if the relative path starting in @p ctx_node reaches the document root via double dots.
  * @param[in] expr Parsed path.
@@ -180,7 +181,7 @@
  * @return LY_ERR value.
  */
 LY_ERR ly_path_compile_leafref(const struct ly_ctx *ctx, const struct lysc_node *ctx_node,
-        const struct lysc_ext_instance *ext, const struct lyxp_expr *expr, uint8_t oper, uint8_t target,
+        const struct lysc_ext_instance *top_ext, const struct lyxp_expr *expr, uint8_t oper, uint8_t target,
         LY_VALUE_FORMAT format, void *prefix_data, struct ly_path **path);
 
 /**
diff --git a/src/plugins_exts.h b/src/plugins_exts.h
index f521d7d..747aa51 100644
--- a/src/plugins_exts.h
+++ b/src/plugins_exts.h
@@ -100,7 +100,7 @@
 /**
  * @brief Extensions API version
  */
-#define LYPLG_EXT_API_VERSION 2
+#define LYPLG_EXT_API_VERSION 3
 
 /**
  * @brief Macro to define plugin information in external plugins
@@ -159,22 +159,26 @@
 typedef void (*lyplg_ext_free_clb)(struct ly_ctx *ctx, struct lysc_ext_instance *ext);
 
 /**
- * @brief Callback for parsing YANG instance data described by an extension instance.
+ * @brief Callback for getting a schema node for a new YANG instance data described by an extension instance.
+ * Needed only if the extension instance supports some nested standard YANG data.
  *
- * This callback is used only for nested data definition (with a standard YANG schema parent).
- * Note that the siblings parsed by this function and directly connected to @p parent must have the flag ::LYD_EXT set.
- *
- * @param[in] in Input handler with the data to parse.
- * @param[in] format Format if the data in @p in.
  * @param[in] ext Compiled extension instance.
- * @param[in,out] parent Data parent to append to.
- * @param[in] parse_opts Parse options, see @ref dataparseroptions. They will always include ::LYD_PARSE_ONLY.
+ * @param[in] parent Parsed parent data node. Set if @p sparent is NULL.
+ * @param[in] sparent Schema parent node. Set if @p parent is NULL.
+ * @param[in] prefix Element prefix, if any.
+ * @param[in] prefix_len Length of @p prefix.
+ * @param[in] format Format of @p prefix.
+ * @param[in] prefix_data Format-specific prefix data.
+ * @param[in] name Element name.
+ * @param[in] name_len Length of @p name.
+ * @param[out] snode Schema node to use for parsing the node.
  * @return LY_SUCCESS on success.
  * @return LY_ENOT if the data are not described by @p ext.
  * @return LY_ERR on error.
  */
-typedef LY_ERR (*lyplg_ext_data_parse_clb)(struct ly_in *in, LYD_FORMAT format, struct lysc_ext_instance *ext,
-        struct lyd_node *parent, uint32_t parse_opts);
+typedef LY_ERR (*lyplg_ext_data_snode_clb)(struct lysc_ext_instance *ext, const struct lyd_node *parent,
+        const struct lysc_node *sparent, const char *prefix, size_t prefix_len, LY_VALUE_FORMAT format, void *prefix_data,
+        const char *name, size_t name_len, const struct lysc_node **snode);
 
 /**
  * @brief Callback for validating parsed YANG instance data described by an extension instance.
@@ -182,12 +186,14 @@
  * This callback is used only for nested data definition (with a standard YANG schema parent).
  *
  * @param[in] ext Compiled extension instance.
- * @param[in] sibling First sibling parsed by ::lyplg_ext_data_parse_clb.
+ * @param[in] sibling First sibling with schema node returned by ::lyplg_ext_data_snode_clb.
  * @param[in] val_opts Validation options, see @ref datavalidationoptions.
+ * @param[out] diff Optional diff with any changes made by the validation.
  * @return LY_SUCCESS on success.
  * @return LY_ERR on error.
  */
-typedef LY_ERR (*lyplg_ext_data_validate_clb)(struct lysc_ext_instance *ext, struct lyd_node *sibling, uint32_t val_opts);
+typedef LY_ERR (*lyplg_ext_data_validate_clb)(struct lysc_ext_instance *ext, struct lyd_node *sibling, uint32_t val_opts,
+        struct lyd_node **diff);
 
 /**
  * @brief Extension plugin implementing various aspects of a YANG extension
@@ -200,7 +206,7 @@
                                                  instance */
     lyplg_ext_free_clb free;                /**< free the extension-specific data created by its compilation */
 
-    lyplg_ext_data_parse_clb parse;         /**< callback to parse data instance according to the extension definition */
+    lyplg_ext_data_snode_clb snode;         /**< callback to get schema node for nested YANG data */
     lyplg_ext_data_validate_clb validate;   /**< callback to validate parsed data instances according to the extension
                                                  definition */
 };
diff --git a/src/plugins_exts/metadata.c b/src/plugins_exts/metadata.c
index bc70694..eebb434 100644
--- a/src/plugins_exts/metadata.c
+++ b/src/plugins_exts/metadata.c
@@ -163,7 +163,7 @@
         .plugin.compile = &annotation_compile,
         .plugin.sprinter = &annotation_schema_printer,
         .plugin.free = annotation_free,
-        .plugin.parse = NULL,
+        .plugin.snode = NULL,
         .plugin.validate = NULL
     },
     {0}     /* terminating zeroed record */
diff --git a/src/plugins_exts/nacm.c b/src/plugins_exts/nacm.c
index d8e1ca8..aa0d0e8 100644
--- a/src/plugins_exts/nacm.c
+++ b/src/plugins_exts/nacm.c
@@ -160,7 +160,7 @@
         .plugin.compile = &nacm_compile,
         .plugin.sprinter = NULL,
         .plugin.free = NULL,
-        .plugin.parse = NULL,
+        .plugin.snode = NULL,
         .plugin.validate = NULL
     }, {
         .module = "ietf-netconf-acm",
@@ -171,7 +171,7 @@
         .plugin.compile = &nacm_compile,
         .plugin.sprinter = NULL,
         .plugin.free = NULL,
-        .plugin.parse = NULL,
+        .plugin.snode = NULL,
         .plugin.validate = NULL
     }, {
         .module = "ietf-netconf-acm",
@@ -182,7 +182,7 @@
         .plugin.compile = &nacm_compile,
         .plugin.sprinter = NULL,
         .plugin.free = NULL,
-        .plugin.parse = NULL,
+        .plugin.snode = NULL,
         .plugin.validate = NULL
     }, {
         .module = "ietf-netconf-acm",
@@ -193,7 +193,7 @@
         .plugin.compile = &nacm_compile,
         .plugin.sprinter = NULL,
         .plugin.free = NULL,
-        .plugin.parse = NULL,
+        .plugin.snode = NULL,
         .plugin.validate = NULL
     },
     {0} /* terminating zeroed item */
diff --git a/src/plugins_exts/schema_mount.c b/src/plugins_exts/schema_mount.c
index 5ba5f2b..81e64de 100644
--- a/src/plugins_exts/schema_mount.c
+++ b/src/plugins_exts/schema_mount.c
@@ -24,6 +24,7 @@
 #include "libyang.h"
 #include "log.h"
 #include "plugins_exts.h"
+#include "plugins_types.h"
 #include "tree_data.h"
 #include "tree_schema.h"
 
@@ -164,6 +165,7 @@
 schema_mount_compile(struct lysc_ctx *cctx, const struct lysp_ext_instance *p_ext, struct lysc_ext_instance *c_ext)
 {
     const struct lys_module *cur_mod;
+    const struct lysc_node *node;
     struct lyplg_ext_sm *sm_data;
 
     assert(!strcmp(p_ext->name, "yangmnt:mount-point"));
@@ -195,8 +197,14 @@
     }
     c_ext->data = sm_data;
 
+    /* find the owner module */
+    node = c_ext->parent;
+    while (node->parent) {
+        node = node->parent;
+    }
+
     /* reuse/init shared schema */
-    sm_data->shared = schema_mount_compile_find_shared(c_ext->module, c_ext);
+    sm_data->shared = schema_mount_compile_find_shared(node->module, c_ext);
     if (sm_data->shared) {
         ++sm_data->shared->ref_count;
     } else {
@@ -503,62 +511,32 @@
 }
 
 /**
- * @brief Parse callback for schema mount.
- * Check if data if valid for schema mount and inserts it to the parent.
+ * @brief Snode callback for schema mount.
+ * Check if data are valid for schema mount and returns their schema node.
  */
 static LY_ERR
-schema_mount_parse(struct ly_in *in, LYD_FORMAT format, struct lysc_ext_instance *ext, struct lyd_node *parent,
-        uint32_t parse_opts)
+schema_mount_snode(struct lysc_ext_instance *ext, const struct lyd_node *parent, const struct lysc_node *sparent,
+        const char *prefix, size_t prefix_len, LY_VALUE_FORMAT format, void *prefix_data, const char *name, size_t name_len,
+        const struct lysc_node **snode)
 {
-    LY_ERR ret = LY_SUCCESS, r;
+    LY_ERR r;
+    const struct lys_module *mod;
     const struct ly_ctx *ext_ctx;
-    struct lyd_node *subtree, *first = NULL;
-    struct ly_err_item *err;
-    uint32_t old_log_opts;
 
     /* get context based on ietf-yang-library data */
     if ((r = schema_mount_get_ctx(ext, &ext_ctx))) {
         return r;
     }
 
-    /* prepare opts */
-    old_log_opts = ly_log_options(LY_LOSTORE_LAST);
-    assert(parse_opts & LYD_PARSE_ONLY);
-    parse_opts |= LYD_PARSE_SUBTREE;
-
-    do {
-        /* parse by nested subtrees */
-        r = lyd_parse_data(ext_ctx, NULL, in, format, parse_opts, 0, &subtree);
-        if (r && (r != LY_ENOT)) {
-            /* error, maybe valid, maybe not, print as verbose */
-            err = ly_err_first(ext_ctx);
-            if (!err) {
-                lyplg_ext_log(ext, LY_LLVRB, 0, NULL, "Unknown parsing error (err code %d).", r);
-            } else {
-                lyplg_ext_log(ext, LY_LLVRB, 0, NULL, "%s (err code %d).", err->msg, err->no);
-            }
-            ret = LY_ENOT;
-            goto cleanup;
-        }
-
-        /* set the special flag and insert into siblings */
-        subtree->flags |= LYD_EXT;
-        lyd_insert_sibling(first, subtree, &first);
-    } while (r == LY_ENOT);
-
-    /* append to parent */
-    if (first && (r = lyd_insert_ext(parent, first))) {
-        lyplg_ext_log(ext, LY_LLERR, r, NULL, "Failed to append parsed data.");
-        ret = r;
-        goto cleanup;
+    /* get the module */
+    mod = lyplg_type_identity_module(ext_ctx, parent ? parent->schema : sparent, prefix, prefix_len, format, prefix_data);
+    if (!mod) {
+        return LY_ENOT;
     }
 
-cleanup:
-    ly_log_options(old_log_opts);
-    if (ret) {
-        lyd_free_siblings(first);
-    }
-    return ret;
+    /* get the top-level schema node */
+    *snode = lys_find_child(NULL, mod, name, name_len, 0, 0);
+    return *snode ? LY_SUCCESS : LY_ENOT;
 }
 
 /**
@@ -679,12 +657,13 @@
  * @brief Validate callback for schema mount.
  */
 static LY_ERR
-schema_mount_validate(struct lysc_ext_instance *ext, struct lyd_node *sibling, uint32_t val_opts)
+schema_mount_validate(struct lysc_ext_instance *ext, struct lyd_node *sibling, uint32_t val_opts, struct lyd_node **diff)
 {
     LY_ERR ret = LY_SUCCESS;
     uint32_t old_log_opts, i;
     struct ly_err_item *err;
     struct lyd_node *iter, *ext_data = NULL, *ref_first = NULL, *orig_parent = lyd_parent(sibling);
+    struct lyd_node *ext_diff = NULL, *diff_parent = NULL;
     ly_bool ext_data_free = 0;
     struct ly_set *ref_set = NULL;
 
@@ -727,7 +706,7 @@
     old_log_opts = ly_log_options(LY_LOSTORE_LAST);
 
     /* validate all the data */
-    ret = lyd_validate_all(&sibling, NULL, val_opts, NULL);
+    ret = lyd_validate_all(&sibling, NULL, val_opts, diff ? &ext_diff : NULL);
     ly_log_options(old_log_opts);
 
     /* restore sibling tree */
@@ -753,9 +732,41 @@
         goto cleanup;
     }
 
+    /* create proper diff */
+    if (diff && ext_diff) {
+        /* diff nodes from an extension instance */
+        LY_LIST_FOR(ext_diff, iter) {
+            iter->flags |= LYD_EXT;
+        }
+
+        /* create the parent and insert the diff */
+        if ((ret = lyd_dup_single(lyd_parent(sibling), NULL, LYD_DUP_WITH_PARENTS | LYD_DUP_NO_META, &diff_parent))) {
+            goto cleanup;
+        }
+        if ((ret = lyd_insert_ext(diff_parent, ext_diff))) {
+            goto cleanup;
+        }
+        ext_diff = NULL;
+
+        /* go top-level and set the operation */
+        while (lyd_parent(diff_parent)) {
+            diff_parent = lyd_parent(diff_parent);
+        }
+        if ((ret = lyd_new_meta(LYD_CTX(diff_parent), diff_parent, NULL, "yang:operation", "none", 0, NULL))) {
+            goto cleanup;
+        }
+
+        /* finally merge into the global diff */
+        if ((ret = lyd_diff_merge_all(diff, diff_parent, LYD_DIFF_MERGE_DEFAULTS))) {
+            goto cleanup;
+        }
+    }
+
 cleanup:
     ly_set_free(ref_set, NULL);
     lyd_free_siblings(ref_first);
+    lyd_free_tree(ext_diff);
+    lyd_free_all(diff_parent);
     if (ext_data_free) {
         lyd_free_all(ext_data);
     }
@@ -811,7 +822,7 @@
         .plugin.compile = &schema_mount_compile,
         .plugin.sprinter = NULL,
         .plugin.free = &schema_mount_free,
-        .plugin.parse = &schema_mount_parse,
+        .plugin.snode = &schema_mount_snode,
         .plugin.validate = &schema_mount_validate
     },
     {0} /* terminating zeroed item */
diff --git a/src/plugins_exts/yangdata.c b/src/plugins_exts/yangdata.c
index 55a03e3..b2e6f62 100644
--- a/src/plugins_exts/yangdata.c
+++ b/src/plugins_exts/yangdata.c
@@ -174,7 +174,7 @@
         .plugin.compile = &yangdata_compile,
         .plugin.sprinter = &yangdata_schema_printer,
         .plugin.free = yangdata_free,
-        .plugin.parse = NULL,
+        .plugin.snode = NULL,
         .plugin.validate = NULL
     },
     {0}     /* terminating zeroed record */
diff --git a/src/plugins_types.h b/src/plugins_types.h
index e9aa723..fe08c03 100644
--- a/src/plugins_types.h
+++ b/src/plugins_types.h
@@ -452,7 +452,7 @@
  * @p value_len is always correct. All store functions have to free a dynamically allocated @p value in all
  * cases (even on error).
  *
- * @param[in] ctx libyang Context
+ * @param[in] ctx libyang context
  * @param[in] type Type of the value being stored.
  * @param[in] value Value to be stored.
  * @param[in] value_len Length (number of bytes) of the given @p value.
@@ -461,14 +461,14 @@
  * @param[in] prefix_data Format-specific data for resolving any prefixes (see ly_resolve_prefix()).
  * @param[in] hints Bitmap of [value hints](@ref lydvalhints) of all the allowed value types.
  * @param[in] ctx_node Schema context node of @p value, may be NULL for metadata.
- * @param[out] storage Storage for the value in the type's specific encoding. Except for _canonical, all the members
+ * @param[out] storage Storage for the value in the type's specific encoding. Except for _canonical_, all the members
  * should be filled by the plugin (if it fills them at all).
  * @param[in,out] unres Global unres structure for newly implemented modules.
  * @param[out] err Optionally provided error information in case of failure. If not provided to the caller, a generic
  * error message is prepared instead. The error structure can be created by ::ly_err_new().
  * @return LY_SUCCESS on success,
  * @return LY_EINCOMPLETE in case the ::lyplg_type_validate_clb should be called to finish value validation in data,
- * @return LY_ERR value on error.
+ * @return LY_ERR value on error, @p storage must not have any pointers to dynamic memory.
  */
 LIBYANG_API_DECL typedef LY_ERR (*lyplg_type_store_clb)(const struct ly_ctx *ctx, const struct lysc_type *type,
         const void *value, size_t value_len, uint32_t options, LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints,
@@ -481,7 +481,7 @@
  * in case the ::lyplg_type_store_clb callback returned ::LY_EINCOMPLETE for the value to be valid. However, this
  * callback can be called even in other cases (such as separate/repeated validation).
  *
- * @param[in] ctx libyang Context
+ * @param[in] ctx libyang context
  * @param[in] type Original type of the value (not necessarily the stored one) being validated.
  * @param[in] ctx_node The value data context node for validation.
  * @param[in] tree External data tree (e.g. when validating RPC/Notification) with possibly referenced data.
diff --git a/src/printer_data.h b/src/printer_data.h
index ff938de..fb2a5fb 100644
--- a/src/printer_data.h
+++ b/src/printer_data.h
@@ -176,7 +176,18 @@
  * @param[in] options [Data printer flags](@ref dataprinterflags).
  * @return LY_ERR value.
  */
-LIBYANG_API_DECL LY_ERR lyd_print_clb(ly_write_clb writeclb, void *user_data, const struct lyd_node *root, LYD_FORMAT format, uint32_t options);
+LIBYANG_API_DECL LY_ERR lyd_print_clb(ly_write_clb writeclb, void *user_data, const struct lyd_node *root,
+        LYD_FORMAT format, uint32_t options);
+
+/**
+ * @brief Check whether the node should be printed based on the printing options.
+ *
+ * @param[in] node Node to check.
+ * @param[in] options [Data printer flags](@ref dataprinterflags).
+ * @return 0 if not,
+ * @return non-0 if should be printed.
+ */
+LIBYANG_API_DECL ly_bool lyd_node_should_print(const struct lyd_node *node, uint32_t options);
 
 #ifdef __cplusplus
 }
diff --git a/src/printer_json.c b/src/printer_json.c
index 2e3ff48..a301075 100644
--- a/src/printer_json.c
+++ b/src/printer_json.c
@@ -36,6 +36,7 @@
 struct jsonpr_ctx {
     struct ly_out *out;         /**< output specification */
     const struct lyd_node *root;    /**< root node of the subtree being printed */
+    const struct lyd_node *parent;  /**< parent of the node being printed */
     uint16_t level;             /**< current indentation level: 0 - no formatting, >= 1 indentation levels */
     uint32_t options;           /**< [Data printer flags](@ref dataprinterflags) */
     const struct ly_ctx *ctx;   /**< libyang context */
@@ -259,7 +260,7 @@
 json_print_member(struct jsonpr_ctx *pctx, const struct lyd_node *node, ly_bool is_attr)
 {
     PRINT_COMMA;
-    if ((LEVEL == 1) || json_nscmp(node, lyd_parent(node))) {
+    if ((LEVEL == 1) || json_nscmp(node, pctx->parent)) {
         /* print "namespace" */
         ly_print_(pctx->out, "%*s\"%s%s:%s\":%s", INDENT, is_attr ? "@" : "",
                 node_prefix(node), node->schema->name, DO_FORMAT ? " " : "");
@@ -529,6 +530,7 @@
 {
     LY_ERR ret = LY_SUCCESS;
     struct lyd_node *iter;
+    const struct lyd_node *prev_parent;
     uint32_t prev_opts, prev_lo;
 
     assert(any->schema->nodetype & LYD_NODE_ANY);
@@ -558,21 +560,24 @@
         LEVEL_INC;
 
         /* close opening tag and print data */
+        prev_parent = pctx->parent;
         prev_opts = pctx->options;
+        pctx->parent = &any->node;
         pctx->options &= ~LYD_PRINT_WITHSIBLINGS;
         LY_LIST_FOR(any->value.tree, iter) {
             ret = json_print_node(pctx, iter);
             LY_CHECK_ERR_RET(ret, LEVEL_DEC, ret);
         }
+        pctx->parent = prev_parent;
         pctx->options = prev_opts;
 
         /* terminate the object */
+        LEVEL_DEC;
         if (DO_FORMAT) {
             ly_print_(pctx->out, "\n%*s}", INDENT);
         } else {
             ly_print_(pctx->out, "}");
         }
-        LEVEL_DEC;
         break;
     case LYD_ANYDATA_JSON:
         if (!any->value.json) {
@@ -622,19 +627,24 @@
 json_print_inner(struct jsonpr_ctx *pctx, const struct lyd_node *node)
 {
     struct lyd_node *child;
+    const struct lyd_node *prev_parent;
+    struct lyd_node_opaq *opaq = NULL;
     ly_bool has_content = 0;
 
     LY_LIST_FOR(lyd_child(node), child) {
-        if (ly_should_print(child, pctx->options)) {
+        if (lyd_node_should_print(child, pctx->options)) {
             break;
         }
     }
     if (node->meta || child) {
         has_content = 1;
     }
+    if (!node->schema) {
+        opaq = (struct lyd_node_opaq *)node;
+    }
 
     if ((node->schema && (node->schema->nodetype == LYS_LIST)) ||
-            (!node->schema && (((struct lyd_node_opaq *)node)->hints & LYD_NODEHINT_LIST))) {
+            (opaq && (opaq->hints != LYD_HINT_DATA) && (opaq->hints & LYD_NODEHINT_LIST))) {
         ly_print_(pctx->out, "%s%*s{%s", (is_open_array(pctx, node) && (pctx->level_printed >= pctx->level)) ?
                 (DO_FORMAT ? ",\n" : ",") : "", INDENT, (DO_FORMAT && has_content) ? "\n" : "");
     } else {
@@ -646,9 +656,12 @@
     json_print_attributes(pctx, node, 1);
 
     /* print children */
+    prev_parent = pctx->parent;
+    pctx->parent = node;
     LY_LIST_FOR(lyd_child(node), child) {
         LY_CHECK_RET(json_print_node(pctx, child));
     }
+    pctx->parent = prev_parent;
 
     LEVEL_DEC;
     if (DO_FORMAT && has_content) {
@@ -844,7 +857,7 @@
     }
 
     if (first) {
-        LY_CHECK_RET(json_print_member2(pctx, lyd_parent(&node->node), node->format, &node->name, 0));
+        LY_CHECK_RET(json_print_member2(pctx, pctx->parent, node->format, &node->name, 0));
 
         if (node->hints & (LYD_NODEHINT_LIST | LYD_NODEHINT_LEAFLIST)) {
             LY_CHECK_RET(json_print_array_open(pctx, &node->node));
@@ -861,10 +874,10 @@
     } else {
         if (node->hints & LYD_VALHINT_EMPTY) {
             ly_print_(pctx->out, "[null]");
-        } else if (node->hints & (LYD_VALHINT_BOOLEAN | LYD_VALHINT_DECNUM)) {
+        } else if ((node->hints & (LYD_VALHINT_BOOLEAN | LYD_VALHINT_DECNUM)) && !(node->hints & LYD_VALHINT_NUM64)) {
             ly_print_(pctx->out, "%s", node->value);
         } else {
-            /* string */
+            /* string or a large number */
             ly_print_(pctx->out, "\"%s\"", node->value);
         }
         LEVEL_PRINTED;
@@ -891,7 +904,7 @@
 static LY_ERR
 json_print_node(struct jsonpr_ctx *pctx, const struct lyd_node *node)
 {
-    if (!ly_should_print(node, pctx->options)) {
+    if (!lyd_node_should_print(node, pctx->options)) {
         if (json_print_array_is_last_inst(pctx, node)) {
             json_print_array_close(pctx);
         }
@@ -949,6 +962,7 @@
     }
 
     pctx.out = out;
+    pctx.parent = NULL;
     pctx.level = 1;
     pctx.level_printed = 0;
     pctx.options = options;
diff --git a/src/printer_lyb.c b/src/printer_lyb.c
index b330e4c..9364826 100644
--- a/src/printer_lyb.c
+++ b/src/printer_lyb.c
@@ -397,7 +397,7 @@
  *
  * @param[in] str String to write.
  * @param[in] str_len Length of @p str.
- * @param[in] len_size Size of @ str_len in bytes.
+ * @param[in] len_size Size of @p str_len in bytes.
  * @param[in] out Out structure.
  * @param[in] lybctx LYB context.
  * @return LY_ERR value.
@@ -456,20 +456,16 @@
 lyb_print_model(struct ly_out *out, const struct lys_module *mod, struct lylyb_ctx *lybctx)
 {
     uint16_t revision;
+    int r;
 
     /* model name length and model name */
-    if (mod) {
-        LY_CHECK_RET(lyb_write_string(mod->name, 0, sizeof(uint16_t), out, lybctx));
-    } else {
-        LY_CHECK_RET(lyb_write_number(0, 2, out, lybctx));
-        return LY_SUCCESS;
-    }
+    LY_CHECK_RET(lyb_write_string(mod->name, 0, sizeof(uint16_t), out, lybctx));
 
     /* model revision as XXXX XXXX XXXX XXXX (2B) (year is offset from 2000)
      *                   YYYY YYYM MMMD DDDD */
     revision = 0;
-    if (mod && mod->revision) {
-        int r = atoi(mod->revision);
+    if (mod->revision) {
+        r = atoi(mod->revision);
         r -= LYB_REV_YEAR_OFFSET;
         r <<= LYB_REV_YEAR_SHIFT;
 
@@ -486,10 +482,8 @@
     }
     LY_CHECK_RET(lyb_write_number(revision, sizeof revision, out, lybctx));
 
-    if (mod) {
-        /* fill cached hashes, if not already */
-        lyb_cache_module_hash(mod);
-    }
+    /* fill cached hashes, if not already */
+    lyb_cache_module_hash(mod);
 
     return LY_SUCCESS;
 }
@@ -923,6 +917,35 @@
 }
 
 /**
+ * @brief Print LYB node type.
+ *
+ * @param[in] out Out structure.
+ * @param[in] node Current data node to print.
+ * @param[in] lybctx LYB context.
+ * @return LY_ERR value.
+ */
+static LY_ERR
+lyb_print_lyb_type(struct ly_out *out, const struct lyd_node *node, struct lyd_lyb_ctx *lybctx)
+{
+    enum lylyb_node_type lyb_type;
+
+    if (node->flags & LYD_EXT) {
+        assert(node->schema);
+        lyb_type = LYB_NODE_EXT;
+    } else if (!node->schema) {
+        lyb_type = LYB_NODE_OPAQ;
+    } else if (!lysc_data_parent(node->schema)) {
+        lyb_type = LYB_NODE_TOP;
+    } else {
+        lyb_type = LYB_NODE_CHILD;
+    }
+
+    LY_CHECK_RET(lyb_write_number(lyb_type, 1, out, lybctx->lybctx));
+
+    return LY_SUCCESS;
+}
+
+/**
  * @brief Print inner node.
  *
  * @param[in] out Out structure.
@@ -1156,15 +1179,21 @@
 {
     const struct lyd_node *node = *printed_node;
 
-    /* write model info first, for all opaque and top-level nodes */
-    if (!node->schema && (!node->parent || !node->parent->schema)) {
-        LY_CHECK_RET(lyb_print_model(out, NULL, lybctx->lybctx));
-    } else if (node->schema && !lysc_data_parent(node->schema)) {
+    /* write node type */
+    LY_CHECK_RET(lyb_print_lyb_type(out, node, lybctx));
+
+    /* write model info first */
+    if (node->schema && ((node->flags & LYD_EXT) || !lysc_data_parent(node->schema))) {
         LY_CHECK_RET(lyb_print_model(out, node->schema->module, lybctx->lybctx));
     }
 
-    /* write schema hash */
-    LY_CHECK_RET(lyb_print_schema_hash(out, (struct lysc_node *)node->schema, sibling_ht, lybctx->lybctx));
+    if (node->flags & LYD_EXT) {
+        /* write schema node name */
+        LY_CHECK_RET(lyb_write_string(node->schema->name, 0, sizeof(uint16_t), out, lybctx->lybctx));
+    } else {
+        /* write schema hash */
+        LY_CHECK_RET(lyb_print_schema_hash(out, (struct lysc_node *)node->schema, sibling_ht, lybctx->lybctx));
+    }
 
     if (!node->schema) {
         LY_CHECK_RET(lyb_print_node_opaq(out, (struct lyd_node_opaq *)node, lybctx));
diff --git a/src/printer_tree.c b/src/printer_tree.c
index 525e505..b5b9666 100644
--- a/src/printer_tree.c
+++ b/src/printer_tree.c
@@ -3974,7 +3974,7 @@
     ly_parse_nodeid(&id, &prefix, &prefix_len, &name, &name_len);
     if (prefix) {
         mod = ly_resolve_prefix(pmod->mod->ctx, prefix, prefix_len, LY_VALUE_SCHEMA, pmod);
-        ret = mod->parsed == pmod;
+        ret = mod ? (mod->parsed == pmod) : 0;
     } else {
         ret = 1;
     }
diff --git a/src/printer_xml.c b/src/printer_xml.c
index 22c6af6..63c8259 100644
--- a/src/printer_xml.c
+++ b/src/printer_xml.c
@@ -349,7 +349,7 @@
     xml_print_node_open(pctx, &node->node);
 
     LY_LIST_FOR(node->child, child) {
-        if (ly_should_print(child, pctx->options)) {
+        if (lyd_node_should_print(child, pctx->options)) {
             break;
         }
     }
@@ -511,7 +511,7 @@
     LY_ERR ret = LY_SUCCESS;
     uint32_t ns_count;
 
-    if (!ly_should_print(node, pctx->options)) {
+    if (!lyd_node_should_print(node, pctx->options)) {
         /* do not print at all */
         return LY_SUCCESS;
     }
diff --git a/src/printer_yang.c b/src/printer_yang.c
index e1e4f20..8b7e593 100644
--- a/src/printer_yang.c
+++ b/src/printer_yang.c
@@ -339,7 +339,8 @@
 }
 
 static void
-ypr_unsigned(struct lys_ypr_ctx *pctx, enum ly_stmt substmt, uint8_t substmt_index, void *exts, unsigned long int attr_value, ly_bool *flag)
+ypr_unsigned(struct lys_ypr_ctx *pctx, enum ly_stmt substmt, uint8_t substmt_index, void *exts,
+        unsigned long int attr_value, ly_bool *flag)
 {
     char *str;
 
@@ -353,7 +354,8 @@
 }
 
 static void
-ypr_signed(struct lys_ypr_ctx *pctx, enum ly_stmt substmt, uint8_t substmt_index, void *exts, signed long int attr_value, ly_bool *flag)
+ypr_signed(struct lys_ypr_ctx *pctx, enum ly_stmt substmt, uint8_t substmt_index, void *exts, signed long int attr_value,
+        ly_bool *flag)
 {
     char *str;
 
@@ -575,18 +577,18 @@
 static void
 yprp_restr(struct lys_ypr_ctx *pctx, const struct lysp_restr *restr, enum ly_stmt stmt, ly_bool *flag)
 {
-    ly_bool inner_flag = 0;
+    ly_bool inner_flag = 0, singleline;
+    const char *text;
 
     if (!restr) {
         return;
     }
 
     ypr_open(pctx->out, flag);
-    ly_print_(pctx->out, "%*s%s \"", INDENT, ly_stmt2str(stmt));
-    ypr_encode(pctx->out,
-            (restr->arg.str[0] != LYSP_RESTR_PATTERN_NACK && restr->arg.str[0] != LYSP_RESTR_PATTERN_ACK) ?
-            restr->arg.str : &restr->arg.str[1], -1);
-    ly_print_(pctx->out, "\"");
+    text = ((restr->arg.str[0] != LYSP_RESTR_PATTERN_NACK) && (restr->arg.str[0] != LYSP_RESTR_PATTERN_ACK)) ?
+            restr->arg.str : restr->arg.str + 1;
+    singleline = strchr(text, '\n') ? 0 : 1;
+    ypr_text(pctx, ly_stmt2str(stmt), text, singleline, 0);
 
     LEVEL++;
     yprp_extension_instances(pctx, stmt, 0, restr->exts, &inner_flag, 0);
diff --git a/src/schema_compile_amend.c b/src/schema_compile_amend.c
index 199dc96..483d759 100644
--- a/src/schema_compile_amend.c
+++ b/src/schema_compile_amend.c
@@ -305,14 +305,19 @@
 static LY_ERR
 lysp_ext_dup(const struct ly_ctx *ctx, struct lysp_ext_instance *ext, const struct lysp_ext_instance *orig_ext)
 {
-    *ext = *orig_ext;
     DUP_STRING_RET(ctx, orig_ext->name, ext->name);
     DUP_STRING_RET(ctx, orig_ext->argument, ext->argument);
+    ext->format = orig_ext->format;
     ext->parsed = NULL;
+    LY_CHECK_RET(ly_dup_prefix_data(ctx, orig_ext->format, orig_ext->prefix_data, &ext->prefix_data));
 
     ext->child = NULL;
     LY_CHECK_RET(lysp_ext_children_dup(ctx, &ext->child, orig_ext->child));
 
+    ext->parent = orig_ext->parent;
+    ext->parent_stmt = orig_ext->parent_stmt;
+    ext->parent_stmt_index = orig_ext->parent_stmt_index;
+    ext->flags = orig_ext->flags;
     return LY_SUCCESS;
 }
 
diff --git a/src/schema_compile_node.c b/src/schema_compile_node.c
index f052184..5037876 100644
--- a/src/schema_compile_node.c
+++ b/src/schema_compile_node.c
@@ -3202,6 +3202,7 @@
     struct lysp_node_list *list_p = (struct lysp_node_list *)pnode;
     struct lysc_node_list *list = (struct lysc_node_list *)node;
     struct lysp_node *child_p;
+    struct lysc_node *parent;
     struct lysc_node_leaf *key, *prev_key = NULL;
     size_t len;
     const char *keystr, *delim;
@@ -3224,9 +3225,22 @@
     LY_CHECK_GOTO(ret, done);
 
     /* keys */
-    if ((list->flags & LYS_CONFIG_W) && (!list_p->key || !list_p->key[0])) {
-        LOGVAL(ctx->ctx, LYVE_SEMANTICS, "Missing key in list representing configuration data.");
-        return LY_EVALID;
+    if (list->flags & LYS_CONFIG_W) {
+        parent = node;
+        if (ctx->compile_opts & LYS_COMPILE_GROUPING) {
+            /* compiling individual grouping, we can check this only if there is an explicit config set */
+            while (parent) {
+                if (parent->flags & LYS_SET_CONFIG) {
+                    break;
+                }
+                parent = parent->parent;
+            }
+        }
+
+        if (parent && (!list_p->key || !list_p->key[0])) {
+            LOGVAL(ctx->ctx, LYVE_SEMANTICS, "Missing key in list representing configuration data.");
+            return LY_EVALID;
+        }
     }
 
     /* find all the keys (must be direct children) */
diff --git a/src/tree_data.c b/src/tree_data.c
index 46279a8..3003b4e 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -885,8 +885,10 @@
 lyd_new_inner(struct lyd_node *parent, const struct lys_module *module, const char *name, ly_bool output,
         struct lyd_node **node)
 {
+    LY_ERR r;
     struct lyd_node *ret = NULL;
     const struct lysc_node *schema;
+    struct lysc_ext_instance *ext = NULL;
     const struct ly_ctx *ctx = parent ? LYD_CTX(parent) : (module ? module->ctx : NULL);
 
     LY_CHECK_ARG_RET(ctx, parent || module, parent || node, name, LY_EINVAL);
@@ -898,9 +900,18 @@
 
     schema = lys_find_child(parent ? parent->schema : NULL, module, name, 0,
             LYS_CONTAINER | LYS_NOTIF | LYS_RPC | LYS_ACTION, output ? LYS_GETNEXT_OUTPUT : 0);
-    LY_CHECK_ERR_RET(!schema, LOGERR(ctx, LY_EINVAL, "Inner node (not a list) \"%s\" not found.", name), LY_ENOTFOUND);
+    if (!schema && parent) {
+        r = ly_nested_ext_schema(parent, NULL, module->name, strlen(module->name), LY_VALUE_JSON, NULL, name,
+                strlen(name), &schema, &ext);
+        LY_CHECK_RET(r && (r != LY_ENOT), r);
+    }
+    LY_CHECK_ERR_RET(!schema, LOGERR(ctx, LY_EINVAL, "Inner node (container, notif, RPC, or action) \"%s\" not found.",
+            name), LY_ENOTFOUND);
 
     LY_CHECK_RET(lyd_create_inner(schema, &ret));
+    if (ext) {
+        ret->flags |= LYD_EXT;
+    }
     if (parent) {
         lyd_insert_node(parent, NULL, ret, 0);
     }
@@ -958,10 +969,11 @@
 {
     struct lyd_node *ret = NULL, *key;
     const struct lysc_node *schema, *key_s;
+    struct lysc_ext_instance *ext = NULL;
     const struct ly_ctx *ctx = parent ? LYD_CTX(parent) : (module ? module->ctx : NULL);
     const void *key_val;
     uint32_t key_len;
-    LY_ERR rc = LY_SUCCESS;
+    LY_ERR r, rc = LY_SUCCESS;
 
     LY_CHECK_ARG_RET(ctx, parent || module, parent || node, name, LY_EINVAL);
     LY_CHECK_CTX_EQUAL_RET(parent ? LYD_CTX(parent) : NULL, module ? module->ctx : NULL, LY_EINVAL);
@@ -971,6 +983,11 @@
     }
 
     schema = lys_find_child(parent ? parent->schema : NULL, module, name, 0, LYS_LIST, output ? LYS_GETNEXT_OUTPUT : 0);
+    if (!schema && parent) {
+        r = ly_nested_ext_schema(parent, NULL, module->name, strlen(module->name), LY_VALUE_JSON, NULL, name,
+                strlen(name), &schema, &ext);
+        LY_CHECK_RET(r && (r != LY_ENOT), r);
+    }
     LY_CHECK_ERR_RET(!schema, LOGERR(ctx, LY_EINVAL, "List node \"%s\" not found.", name), LY_ENOTFOUND);
 
     /* create list inner node */
@@ -991,6 +1008,9 @@
         lyd_insert_node(ret, NULL, key, 1);
     }
 
+    if (ext) {
+        ret->flags |= LYD_EXT;
+    }
     if (parent) {
         lyd_insert_node(parent, NULL, ret, 0);
     }
@@ -1101,8 +1121,10 @@
 lyd_new_list2(struct lyd_node *parent, const struct lys_module *module, const char *name, const char *keys,
         ly_bool output, struct lyd_node **node)
 {
+    LY_ERR r;
     struct lyd_node *ret = NULL;
     const struct lysc_node *schema;
+    struct lysc_ext_instance *ext = NULL;
     const struct ly_ctx *ctx = parent ? LYD_CTX(parent) : (module ? module->ctx : NULL);
 
     LY_CHECK_ARG_RET(ctx, parent || module, parent || node, name, LY_EINVAL);
@@ -1117,6 +1139,11 @@
 
     /* find schema node */
     schema = lys_find_child(parent ? parent->schema : NULL, module, name, 0, LYS_LIST, output ? LYS_GETNEXT_OUTPUT : 0);
+    if (!schema && parent) {
+        r = ly_nested_ext_schema(parent, NULL, module->name, strlen(module->name), LY_VALUE_JSON, NULL, name, strlen(name),
+                &schema, &ext);
+        LY_CHECK_RET(r && (r != LY_ENOT), r);
+    }
     LY_CHECK_ERR_RET(!schema, LOGERR(ctx, LY_EINVAL, "List node \"%s\" not found.", name), LY_ENOTFOUND);
 
     if ((schema->flags & LYS_KEYLESS) && !keys[0]) {
@@ -1126,6 +1153,9 @@
         /* create the list node */
         LY_CHECK_RET(lyd_create_list2(schema, keys, strlen(keys), &ret));
     }
+    if (ext) {
+        ret->flags |= LYD_EXT;
+    }
     if (parent) {
         lyd_insert_node(parent, NULL, ret, 0);
     }
@@ -1154,9 +1184,10 @@
 _lyd_new_term(struct lyd_node *parent, const struct lys_module *module, const char *name, const void *value,
         size_t value_len, LY_VALUE_FORMAT format, ly_bool output, struct lyd_node **node)
 {
-    LY_ERR rc;
+    LY_ERR r;
     struct lyd_node *ret = NULL;
     const struct lysc_node *schema;
+    struct lysc_ext_instance *ext = NULL;
     const struct ly_ctx *ctx = parent ? LYD_CTX(parent) : (module ? module->ctx : NULL);
 
     LY_CHECK_ARG_RET(ctx, parent || module, parent || node, name, LY_EINVAL);
@@ -1167,10 +1198,17 @@
     }
 
     schema = lys_find_child(parent ? parent->schema : NULL, module, name, 0, LYD_NODE_TERM, output ? LYS_GETNEXT_OUTPUT : 0);
+    if (!schema && parent) {
+        r = ly_nested_ext_schema(parent, NULL, module->name, strlen(module->name), LY_VALUE_JSON, NULL, name,
+                strlen(name), &schema, &ext);
+        LY_CHECK_RET(r && (r != LY_ENOT), r);
+    }
     LY_CHECK_ERR_RET(!schema, LOGERR(ctx, LY_EINVAL, "Term node \"%s\" not found.", name), LY_ENOTFOUND);
 
-    rc = lyd_create_term(schema, value, value_len, NULL, format, NULL, LYD_HINT_DATA, NULL, &ret);
-    LY_CHECK_RET(rc);
+    LY_CHECK_RET(lyd_create_term(schema, value, value_len, NULL, format, NULL, LYD_HINT_DATA, NULL, &ret));
+    if (ext) {
+        ret->flags |= LYD_EXT;
+    }
     if (parent) {
         lyd_insert_node(parent, NULL, ret, 0);
     }
@@ -1234,8 +1272,10 @@
 lyd_new_any(struct lyd_node *parent, const struct lys_module *module, const char *name, const void *value,
         ly_bool use_value, LYD_ANYDATA_VALUETYPE value_type, ly_bool output, struct lyd_node **node)
 {
+    LY_ERR r;
     struct lyd_node *ret = NULL;
     const struct lysc_node *schema;
+    struct lysc_ext_instance *ext = NULL;
     const struct ly_ctx *ctx = parent ? LYD_CTX(parent) : (module ? module->ctx : NULL);
 
     LY_CHECK_ARG_RET(ctx, parent || module, parent || node, name, LY_EINVAL);
@@ -1246,9 +1286,17 @@
     }
 
     schema = lys_find_child(parent ? parent->schema : NULL, module, name, 0, LYD_NODE_ANY, output ? LYS_GETNEXT_OUTPUT : 0);
+    if (!schema && parent) {
+        r = ly_nested_ext_schema(parent, NULL, module->name, strlen(module->name), LY_VALUE_JSON, NULL, name,
+                strlen(name), &schema, &ext);
+        LY_CHECK_RET(r && (r != LY_ENOT), r);
+    }
     LY_CHECK_ERR_RET(!schema, LOGERR(ctx, LY_EINVAL, "Any node \"%s\" not found.", name), LY_ENOTFOUND);
 
     LY_CHECK_RET(lyd_create_any(schema, value, value_type, use_value, &ret));
+    if (ext) {
+        ret->flags |= LYD_EXT;
+    }
     if (parent) {
         lyd_insert_node(parent, NULL, ret, 0);
     }
@@ -1539,7 +1587,7 @@
     struct lysc_type *type;
     struct lyd_node_term *t;
     struct lyd_node *parent;
-    struct lyd_value val = {0};
+    struct lyd_value val;
     ly_bool dflt_change, val_change;
 
     assert(term && term->schema && (term->schema->nodetype & LYD_NODE_TERM));
@@ -1558,9 +1606,10 @@
         /* values differ, switch them */
         type->plugin->free(LYD_CTX(term), &t->value);
         t->value = val;
-        memset(&val, 0, sizeof val);
         val_change = 1;
     } else {
+        /* same values, free the new stored one */
+        type->plugin->free(LYD_CTX(term), &val);
         val_change = 0;
     }
 
@@ -1606,9 +1655,6 @@
     } /* else value changed, LY_SUCCESS */
 
 cleanup:
-    if (val.realtype) {
-        type->plugin->free(LYD_CTX(term), &val);
-    }
     return ret;
 }
 
@@ -2030,6 +2076,9 @@
             goto cleanup;
         }
 
+        if (p[path_idx].ext) {
+            node->flags |= LYD_EXT;
+        }
         if (cur_parent) {
             /* connect to the parent */
             lyd_insert_node(cur_parent, NULL, node, 0);
@@ -2363,13 +2412,11 @@
 
     assert(new_node);
 
-    if (!first_sibling || !new_node->schema) {
+    if (!first_sibling || !new_node->schema || (LYD_CTX(first_sibling) != LYD_CTX(new_node))) {
         /* insert at the end, no next anchor */
         return NULL;
     }
 
-    assert(!first_sibling || (LYD_CTX(first_sibling) == LYD_CTX(new_node)));
-
     getnext_opts = 0;
     if (new_node->schema->flags & LYS_IS_OUTPUT) {
         getnext_opts = LYS_GETNEXT_OUTPUT;
@@ -2589,7 +2636,7 @@
     /* get first sibling */
     first_sibling = parent ? lyd_child(parent) : *first_sibling_p;
 
-    if (last) {
+    if (last || (first_sibling && (first_sibling->flags & LYD_EXT))) {
         /* no next anchor */
         anchor = NULL;
     } else {
@@ -2772,17 +2819,17 @@
 LIBYANG_API_DEF LY_ERR
 lyd_insert_before(struct lyd_node *sibling, struct lyd_node *node)
 {
-    LY_CHECK_ARG_RET(NULL, sibling, node, LY_EINVAL);
+    LY_CHECK_ARG_RET(NULL, sibling, node, sibling != node, LY_EINVAL);
     LY_CHECK_CTX_EQUAL_RET(LYD_CTX(sibling), LYD_CTX(node), LY_EINVAL);
 
     LY_CHECK_RET(lyd_insert_check_schema(NULL, sibling->schema, node->schema));
 
-    if (!(node->schema->nodetype & (LYS_LIST | LYS_LEAFLIST)) || !(node->schema->flags & LYS_ORDBY_USER)) {
+    if (node->schema && (!(node->schema->nodetype & (LYS_LIST | LYS_LEAFLIST)) || !(node->schema->flags & LYS_ORDBY_USER))) {
         LOGERR(LYD_CTX(sibling), LY_EINVAL, "Can be used only for user-ordered nodes.");
         return LY_EINVAL;
     }
-    if (lysc_is_key(sibling->schema)) {
-        LOGERR(LYD_CTX(sibling), LY_EINVAL, "Cannot insert before keys.");
+    if (node->schema && sibling->schema && (node->schema != sibling->schema)) {
+        LOGERR(LYD_CTX(sibling), LY_EINVAL, "Cannot insert before a different schema node instance.");
         return LY_EINVAL;
     }
 
@@ -2796,17 +2843,17 @@
 LIBYANG_API_DEF LY_ERR
 lyd_insert_after(struct lyd_node *sibling, struct lyd_node *node)
 {
-    LY_CHECK_ARG_RET(NULL, sibling, node, LY_EINVAL);
+    LY_CHECK_ARG_RET(NULL, sibling, node, sibling != node, LY_EINVAL);
     LY_CHECK_CTX_EQUAL_RET(LYD_CTX(sibling), LYD_CTX(node), LY_EINVAL);
 
     LY_CHECK_RET(lyd_insert_check_schema(NULL, sibling->schema, node->schema));
 
-    if (!(node->schema->nodetype & (LYS_LIST | LYS_LEAFLIST)) || !(node->schema->flags & LYS_ORDBY_USER)) {
+    if (node->schema && (!(node->schema->nodetype & (LYS_LIST | LYS_LEAFLIST)) || !(node->schema->flags & LYS_ORDBY_USER))) {
         LOGERR(LYD_CTX(sibling), LY_EINVAL, "Can be used only for user-ordered nodes.");
         return LY_EINVAL;
     }
-    if (sibling->next && lysc_is_key(sibling->next->schema)) {
-        LOGERR(LYD_CTX(sibling), LY_EINVAL, "Cannot insert before keys.");
+    if (node->schema && sibling->schema && (node->schema != sibling->schema)) {
+        LOGERR(LYD_CTX(sibling), LY_EINVAL, "Cannot insert after a different schema node instance.");
         return LY_EINVAL;
     }
 
@@ -3439,11 +3486,11 @@
  * @return LY_RRR value.
  */
 static LY_ERR
-lyd_dup_find_schema(const struct lysc_node *schema, const struct ly_ctx *trg_ctx, struct lyd_node *parent,
+lyd_dup_find_schema(const struct lysc_node *schema, const struct ly_ctx *trg_ctx, const struct lyd_node *parent,
         const struct lysc_node **trg_schema)
 {
-    const struct lysc_node *node = NULL, *sparent = NULL;
-    const struct lys_module *mod = NULL;
+    const struct lysc_node *src_parent = NULL, *trg_parent = NULL, *sp, *tp;
+    const struct lys_module *trg_mod = NULL;
     char *path;
 
     if (!schema) {
@@ -3452,32 +3499,52 @@
         return LY_SUCCESS;
     }
 
-    if (parent && parent->schema) {
+    if (lysc_data_parent(schema) && parent && parent->schema) {
         /* start from schema parent */
-        sparent = parent->schema;
-    } else {
-        /* start from module */
-        mod = ly_ctx_get_module_implemented(trg_ctx, schema->module->name);
-        if (!mod) {
-            LOGERR(trg_ctx, LY_ENOTFOUND, "Module \"%s\" not present/implemented in the target context.",
-                    schema->module->name);
+        trg_parent = parent->schema;
+        src_parent = lysc_data_parent(schema);
+    }
+
+    do {
+        /* find the next parent */
+        sp = schema;
+        while (sp->parent != src_parent) {
+            sp = sp->parent;
+        }
+        src_parent = sp;
+
+        if (!src_parent->parent) {
+            /* find the module first */
+            trg_mod = ly_ctx_get_module_implemented(trg_ctx, src_parent->module->name);
+            if (!trg_mod) {
+                LOGERR(trg_ctx, LY_ENOTFOUND, "Module \"%s\" not present/implemented in the target context.",
+                        src_parent->module->name);
+                return LY_ENOTFOUND;
+            }
+        }
+
+        /* find the next parent */
+        assert(trg_parent || trg_mod);
+        tp = NULL;
+        while ((tp = lys_getnext(tp, trg_parent, trg_mod ? trg_mod->compiled : NULL, 0))) {
+            if (!strcmp(tp->name, src_parent->name) && !strcmp(tp->module->name, src_parent->module->name)) {
+                break;
+            }
+        }
+        if (!tp) {
+            /* schema node not found */
+            path = lysc_path(src_parent, LYSC_PATH_LOG, NULL, 0);
+            LOGERR(trg_ctx, LY_ENOTFOUND, "Schema node \"%s\" not found in the target context.", path);
+            free(path);
             return LY_ENOTFOUND;
         }
-    }
 
-    /* find the schema node */
-    while ((node = lys_getnext(node, sparent, mod ? mod->compiled : NULL, 0))) {
-        if (!strcmp(node->module->name, schema->module->name) && !strcmp(node->name, schema->name)) {
-            *trg_schema = node;
-            return LY_SUCCESS;
-        }
-    }
+        trg_parent = tp;
+    } while (schema != src_parent);
 
-    /* schema node not found */
-    path = lysc_path(schema, LYSC_PATH_LOG, NULL, 0);
-    LOGERR(trg_ctx, LY_ENOTFOUND, "Schema node \"%s\" not found in the target context.", path);
-    free(path);
-    return LY_ENOTFOUND;
+    /* success */
+    *trg_schema = trg_parent;
+    return LY_SUCCESS;
 }
 
 /**
@@ -3509,6 +3576,11 @@
 
     LY_CHECK_ARG_RET(NULL, node, LY_EINVAL);
 
+    if (node->flags & LYD_EXT) {
+        /* we need to use the same context */
+        trg_ctx = LYD_CTX(node);
+    }
+
     if (!node->schema) {
         dup = calloc(1, sizeof(struct lyd_node_opaq));
         ((struct lyd_node_opaq *)dup)->ctx = trg_ctx;
@@ -3540,12 +3612,18 @@
     if (options & LYD_DUP_WITH_FLAGS) {
         dup->flags = node->flags;
     } else {
-        dup->flags = (node->flags & LYD_DEFAULT) | LYD_NEW;
+        dup->flags = (node->flags & (LYD_DEFAULT | LYD_EXT)) | LYD_NEW;
     }
     if (trg_ctx == LYD_CTX(node)) {
         dup->schema = node->schema;
     } else {
-        LY_CHECK_GOTO(ret = lyd_dup_find_schema(node->schema, trg_ctx, parent, &dup->schema), error);
+        ret = lyd_dup_find_schema(node->schema, trg_ctx, parent, &dup->schema);
+        if (ret) {
+            /* has no schema but is not an opaque node */
+            free(dup);
+            dup = NULL;
+            goto error;
+        }
     }
     dup->prev = dup;
 
@@ -3611,20 +3689,8 @@
             }
         } else if ((dup->schema->nodetype == LYS_LIST) && !(dup->schema->flags & LYS_KEYLESS)) {
             /* always duplicate keys of a list */
-            child = orig->child;
-            for (const struct lysc_node *key = lysc_node_child(dup->schema);
-                    key && (key->flags & LYS_KEY);
-                    key = key->next) {
-                if (!child) {
-                    /* possibly not keys are present in filtered tree */
-                    break;
-                } else if (child->schema != key) {
-                    /* possibly not all keys are present in filtered tree,
-                     * but there can be also some non-key nodes */
-                    continue;
-                }
+            for (child = orig->child; child && lysc_is_key(child->schema); child = child->next) {
                 LY_CHECK_GOTO(ret = lyd_dup_r(child, trg_ctx, dup, 1, NULL, options, NULL), error);
-                child = child->next;
             }
         }
         lyd_hash(dup);
@@ -4166,8 +4232,8 @@
     ly_bool is_static = 0;
     uint32_t i, depth;
     size_t bufused = 0, len;
-    const struct lyd_node *iter;
-    const struct lys_module *mod;
+    const struct lyd_node *iter, *parent;
+    const struct lys_module *mod, *prev_mod;
     LY_ERR rc = LY_SUCCESS;
 
     LY_CHECK_ARG_RET(NULL, node, NULL);
@@ -4191,11 +4257,12 @@
             /* find the right node */
             for (iter = node, i = 1; i < depth; iter = lyd_parent(iter), ++i) {}
 iter_print:
-            /* print prefix and name */
-            mod = NULL;
-            if (iter->schema && (!iter->parent || !iter->parent->schema ||
-                    (iter->schema->module != iter->parent->schema->module))) {
-                mod = iter->schema->module;
+            /* get the module */
+            mod = iter->schema ? iter->schema->module : lyd_owner_module(iter);
+            parent = lyd_parent(iter);
+            prev_mod = (parent && parent->schema) ? parent->schema->module : lyd_owner_module(parent);
+            if (prev_mod == mod) {
+                mod = NULL;
             }
 
             /* realloc string */
@@ -4295,16 +4362,28 @@
 LIBYANG_API_DEF LY_ERR
 lyd_find_sibling_first(const struct lyd_node *siblings, const struct lyd_node *target, struct lyd_node **match)
 {
-    struct lyd_node **match_p, *iter;
+    struct lyd_node **match_p, *iter, *dup = NULL;
     struct lyd_node_inner *parent;
     ly_bool found;
 
     LY_CHECK_ARG_RET(NULL, target, LY_EINVAL);
-    LY_CHECK_CTX_EQUAL_RET(siblings ? LYD_CTX(siblings) : NULL, LYD_CTX(target), LY_EINVAL);
+    if (!siblings) {
+        /* no data */
+        if (match) {
+            *match = NULL;
+        }
+        return LY_ENOTFOUND;
+    }
 
-    if (!siblings || (siblings->schema && target->schema &&
-            (lysc_data_parent(siblings->schema) != lysc_data_parent(target->schema)))) {
-        /* no data or schema mismatch */
+    if (LYD_CTX(siblings) != LYD_CTX(target)) {
+        /* create a duplicate in this context */
+        LY_CHECK_RET(lyd_dup_single_to_ctx(target, LYD_CTX(siblings), NULL, 0, &dup));
+        target = dup;
+    }
+
+    if ((siblings->schema && target->schema && (lysc_data_parent(siblings->schema) != lysc_data_parent(target->schema)))) {
+        /* schema mismatch */
+        lyd_free_tree(dup);
         if (match) {
             *match = NULL;
         }
@@ -4350,6 +4429,7 @@
         }
     }
 
+    lyd_free_tree(dup);
     if (!siblings) {
         if (match) {
             *match = NULL;
@@ -4466,12 +4546,25 @@
 {
     LY_ERR rc;
     struct lyd_node *target = NULL;
+    const struct lyd_node *parent;
 
     LY_CHECK_ARG_RET(NULL, schema, !(schema->nodetype & (LYS_CHOICE | LYS_CASE)), LY_EINVAL);
-    LY_CHECK_CTX_EQUAL_RET(siblings ? LYD_CTX(siblings) : NULL, schema->module->ctx, LY_EINVAL);
+    if (!siblings) {
+        /* no data */
+        if (match) {
+            *match = NULL;
+        }
+        return LY_ENOTFOUND;
+    }
 
-    if (!siblings || (siblings->schema && (lysc_data_parent(siblings->schema) != lysc_data_parent(schema)))) {
-        /* no data or schema mismatch */
+    if ((LYD_CTX(siblings) != schema->module->ctx)) {
+        /* parent of ext nodes is useless */
+        parent = (siblings->flags & LYD_EXT) ? NULL : lyd_parent(siblings);
+        LY_CHECK_RET(lyd_dup_find_schema(schema, LYD_CTX(siblings), parent, &schema));
+    }
+
+    if (siblings->schema && (lysc_data_parent(siblings->schema) != lysc_data_parent(schema))) {
+        /* schema mismatch */
         if (match) {
             *match = NULL;
         }
diff --git a/src/tree_data.h b/src/tree_data.h
index a5397b8..d1f64f9 100644
--- a/src/tree_data.h
+++ b/src/tree_data.h
@@ -202,6 +202,18 @@
  * need to be provided by a callback:
  *
  * - ::ly_ctx_set_ext_data_clb()
+ *
+ * The mounted data can be parsed directly from data files or created manually using the standard functions. However,
+ * note that the mounted data use **their own context** created as needed. For *inline* data this means that any new
+ * request for a mount-point schema node results in a new context creation because it is impossible to determine
+ * whether any existing context can be used. Also, all these contexts created for the mounted data are **never**
+ * freed automatically except when the parent context is being freed. So, to avoid redundant context creation, it is
+ * always advised to use *shared-schema* for mount-points.
+ *
+ * In case it is not possible and *inline* mount point must be defined, it is still possible to avoid creating
+ * additional contexts. When the top-level node right under a schema node with a mount-point is created, always use
+ * this node for creation of any descendants. So, when using ::lyd_new_path(), use the node as `parent` and specify
+ * relative `path`.
  */
 
 /**
diff --git a/src/tree_data_helpers.c b/src/tree_data_helpers.c
index c5a0e2a..fd773ab 100644
--- a/src/tree_data_helpers.c
+++ b/src/tree_data_helpers.c
@@ -3,7 +3,7 @@
  * @author Radek Krejci <rkrejci@cesnet.cz>
  * @brief Parsing and validation helper functions for data trees
  *
- * Copyright (c) 2015 - 2018 CESNET, z.s.p.o.
+ * Copyright (c) 2015 - 2022 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.
@@ -29,6 +29,7 @@
 #include "log.h"
 #include "lyb.h"
 #include "parser_data.h"
+#include "plugins_exts.h"
 #include "printer_data.h"
 #include "set.h"
 #include "tree.h"
@@ -400,15 +401,17 @@
     return LY_SUCCESS;
 }
 
-void
-lyd_parse_set_data_flags(struct lyd_node *node, struct ly_set *node_when, struct lyd_meta **meta, uint32_t parse_opts)
+LY_ERR
+lyd_parse_set_data_flags(struct lyd_node *node, struct lyd_meta **meta, struct lyd_ctx *lydctx,
+        struct lysc_ext_instance *ext)
 {
     struct lyd_meta *meta2, *prev_meta = NULL;
+    struct lyd_ctx_ext_val *ext_val;
 
     if (lysc_has_when(node->schema)) {
-        if (!(parse_opts & LYD_PARSE_ONLY)) {
+        if (!(lydctx->parse_opts & LYD_PARSE_ONLY)) {
             /* remember we need to evaluate this node's when */
-            LY_CHECK_RET(ly_set_add(node_when, node, 1, NULL), );
+            LY_CHECK_RET(ly_set_add(&lydctx->node_when, node, 1, NULL));
         }
     }
 
@@ -430,6 +433,22 @@
 
         prev_meta = meta2;
     }
+
+    if (ext) {
+        /* parsed for an extension */
+        node->flags |= LYD_EXT;
+
+        if (!(lydctx->parse_opts & LYD_PARSE_ONLY)) {
+            /* rememeber for validation */
+            ext_val = malloc(sizeof *ext_val);
+            LY_CHECK_ERR_RET(!ext_val, LOGMEM(LYD_CTX(node)), LY_EMEM);
+            ext_val->ext = ext;
+            ext_val->sibling = node;
+            LY_CHECK_RET(ly_set_add(&lydctx->ext_val, ext_val, 1, NULL));
+        }
+    }
+
+    return LY_SUCCESS;
 }
 
 /**
@@ -771,6 +790,46 @@
     }
 }
 
+LY_ERR
+ly_nested_ext_schema(const struct lyd_node *parent, const struct lysc_node *sparent, const char *prefix,
+        size_t prefix_len, LY_VALUE_FORMAT format, void *prefix_data, const char *name, size_t name_len,
+        const struct lysc_node **snode, struct lysc_ext_instance **ext)
+{
+    LY_ERR r;
+    LY_ARRAY_COUNT_TYPE u;
+    struct lysc_ext_instance *nested_exts = NULL;
+    lyplg_ext_data_snode_clb ext_snode_cb;
+
+    /* check if there are any nested extension instances */
+    if (parent && parent->schema) {
+        nested_exts = parent->schema->exts;
+    } else if (sparent) {
+        nested_exts = sparent->exts;
+    }
+    LY_ARRAY_FOR(nested_exts, u) {
+        ext_snode_cb = nested_exts[u].def->plugin->snode;
+        if (!ext_snode_cb) {
+            /* not an extension with nested data */
+            continue;
+        }
+
+        /* try to get the schema node */
+        r = ext_snode_cb(&nested_exts[u], parent, sparent, prefix, prefix_len, format, prefix_data, name, name_len, snode);
+        if (!r) {
+            /* data successfully created, remember the ext instance */
+            *ext = &nested_exts[u];
+            return LY_SUCCESS;
+        } else if (r != LY_ENOT) {
+            /* fatal error */
+            return r;
+        }
+        /* data was not from this module, continue */
+    }
+
+    /* no extensions or none matched */
+    return LY_ENOT;
+}
+
 void
 ly_free_prefix_data(LY_VALUE_FORMAT format, void *prefix_data)
 {
diff --git a/src/tree_data_internal.h b/src/tree_data_internal.h
index 3cf45c6..f95c2d8 100644
--- a/src/tree_data_internal.h
+++ b/src/tree_data_internal.h
@@ -22,6 +22,7 @@
 #include <stddef.h>
 
 struct ly_path_predicate;
+struct lyd_ctx;
 struct lysc_module;
 
 #define LY_XML_SUFFIX ".xml"
@@ -128,11 +129,13 @@
  * @brief Set data flags for a newly parsed node.
  *
  * @param[in] node Node to use.
- * @param[in,out] node_when Set of nodes with unresolved when.
  * @param[in,out] meta Node metadata, may be removed from.
- * @param[in] parse_opts Parse options.
+ * @param[in] lydctx Data parsing context.
+ * @param[in] ext Extension instance if @p node was parsed for one.
+ * @return LY_ERR value.
  */
-void lyd_parse_set_data_flags(struct lyd_node *node, struct ly_set *node_when, struct lyd_meta **meta, uint32_t parse_opts);
+LY_ERR lyd_parse_set_data_flags(struct lyd_node *node, struct lyd_meta **meta, struct lyd_ctx *lydctx,
+        struct lysc_ext_instance *ext);
 
 /**
  * @brief Get schema node of a data node. Useful especially for opaque nodes.
@@ -153,6 +156,27 @@
 void lyd_del_move_root(struct lyd_node **root, const struct lyd_node *to_del, const struct lys_module *mod);
 
 /**
+ * @brief Try to get schema node for data with a parent based on an extension instance.
+ *
+ * @param[in] parent Parsed parent data node. Set if @p sparent is NULL.
+ * @param[in] sparent Schema parent node. Set if @p sparent is NULL.
+ * @param[in] prefix Element prefix, if any.
+ * @param[in] prefix_len Length of @p prefix.
+ * @param[in] format Format of @p prefix.
+ * @param[in] prefix_data Format-specific data.
+ * @param[in] name Element name.
+ * @param[in] name_len Length of @p name.
+ * @param[out] snode Found schema node, NULL if no suitable was found.
+ * @param[out] ext Extension instance that provided @p snode.
+ * @return LY_SUCCESS on success;
+ * @return LY_ENOT if no extension instance parsed the data;
+ * @return LY_ERR on error.
+ */
+LY_ERR ly_nested_ext_schema(const struct lyd_node *parent, const struct lysc_node *sparent, const char *prefix,
+        size_t prefix_len, LY_VALUE_FORMAT format, void *prefix_data, const char *name, size_t name_len,
+        const struct lysc_node **snode, struct lysc_ext_instance **ext);
+
+/**
  * @brief Free stored prefix data.
  *
  * @param[in] format Format of the prefixes.
diff --git a/src/tree_schema.c b/src/tree_schema.c
index c7f75ef..1f9fd69 100644
--- a/src/tree_schema.c
+++ b/src/tree_schema.c
@@ -725,76 +725,97 @@
 lysc_path_until(const struct lysc_node *node, const struct lysc_node *parent, LYSC_PATH_TYPE pathtype, char *buffer,
         size_t buflen)
 {
-    const struct lysc_node *iter, *par;
+    const struct lysc_node *iter, *par, *key;
     char *path = NULL;
     int len = 0;
+    ly_bool skip_schema;
 
     if (buffer) {
         LY_CHECK_ARG_RET(node->module->ctx, buflen > 1, NULL);
         buffer[0] = '\0';
     }
 
-    switch (pathtype) {
-    case LYSC_PATH_LOG:
-    case LYSC_PATH_DATA:
-        for (iter = node; iter && (iter != parent) && (len >= 0); iter = iter->parent) {
-            char *s, *id;
-            const char *slash;
+    if ((pathtype == LYSC_PATH_DATA) || (pathtype == LYSC_PATH_DATA_PATTERN)) {
+        /* skip schema-only nodes */
+        skip_schema = 1;
+    } else {
+        skip_schema = 0;
+    }
 
-            if ((pathtype == LYSC_PATH_DATA) && (iter->nodetype & (LYS_CHOICE | LYS_CASE | LYS_INPUT | LYS_OUTPUT))) {
-                /* schema-only node */
-                continue;
-            }
+    for (iter = node; iter && (iter != parent) && (len >= 0); iter = iter->parent) {
+        char *s;
+        const char *slash;
 
-            s = buffer ? strdup(buffer) : path;
-            id = strdup(iter->name);
-            if (parent && (iter->parent == parent)) {
-                slash = "";
-            } else {
-                slash = "/";
-            }
+        if (skip_schema && (iter->nodetype & (LYS_CHOICE | LYS_CASE | LYS_INPUT | LYS_OUTPUT))) {
+            /* schema-only node */
+            continue;
+        }
 
-            if (pathtype == LYSC_PATH_DATA) {
-                par = lysc_data_parent(iter);
-            } else {
-                par = iter->parent;
-            }
+        if ((pathtype == LYSC_PATH_DATA_PATTERN) && (iter->nodetype == LYS_LIST)) {
+            key = NULL;
+            while ((key = lys_getnext(key, iter, NULL, 0)) && lysc_is_key(key)) {
+                s = buffer ? strdup(buffer) : path;
 
-            if (!par || (par->module != iter->module)) {
-                /* print prefix */
+                /* print key predicate */
                 if (buffer) {
-                    len = snprintf(buffer, buflen, "%s%s:%s%s", slash, iter->module->name, id, s ? s : "");
+                    len = snprintf(buffer, buflen, "[%s='%%s']%s", key->name, s ? s : "");
                 } else {
-                    len = asprintf(&path, "%s%s:%s%s", slash, iter->module->name, id, s ? s : "");
+                    len = asprintf(&path, "[%s='%%s']%s", key->name, s ? s : "");
                 }
-            } else {
-                /* prefix is the same as in parent */
-                if (buffer) {
-                    len = snprintf(buffer, buflen, "%s%s%s", slash, id, s ? s : "");
-                } else {
-                    len = asprintf(&path, "%s%s%s", slash, id, s ? s : "");
-                }
-            }
-            free(s);
-            free(id);
+                free(s);
 
-            if (buffer && (buflen <= (size_t)len)) {
-                /* not enough space in buffer */
-                break;
+                if (buffer && (buflen <= (size_t)len)) {
+                    /* not enough space in buffer */
+                    break;
+                }
             }
         }
 
-        if (len < 0) {
-            free(path);
-            path = NULL;
-        } else if (len == 0) {
+        s = buffer ? strdup(buffer) : path;
+        if (parent && (iter->parent == parent)) {
+            slash = "";
+        } else {
+            slash = "/";
+        }
+
+        if (skip_schema) {
+            par = lysc_data_parent(iter);
+        } else {
+            par = iter->parent;
+        }
+
+        if (!par || (par->module != iter->module)) {
+            /* print prefix */
             if (buffer) {
-                strcpy(buffer, "/");
+                len = snprintf(buffer, buflen, "%s%s:%s%s", slash, iter->module->name, iter->name, s ? s : "");
             } else {
-                path = strdup("/");
+                len = asprintf(&path, "%s%s:%s%s", slash, iter->module->name, iter->name, s ? s : "");
+            }
+        } else {
+            /* prefix is the same as in parent */
+            if (buffer) {
+                len = snprintf(buffer, buflen, "%s%s%s", slash, iter->name, s ? s : "");
+            } else {
+                len = asprintf(&path, "%s%s%s", slash, iter->name, s ? s : "");
             }
         }
-        break;
+        free(s);
+
+        if (buffer && (buflen <= (size_t)len)) {
+            /* not enough space in buffer */
+            break;
+        }
+    }
+
+    if (len < 0) {
+        free(path);
+        path = NULL;
+    } else if (len == 0) {
+        if (buffer) {
+            strcpy(buffer, "/");
+        } else {
+            path = strdup("/");
+        }
     }
 
     if (buffer) {
diff --git a/src/tree_schema.h b/src/tree_schema.h
index acfb9bb..9874378 100644
--- a/src/tree_schema.h
+++ b/src/tree_schema.h
@@ -2317,7 +2317,9 @@
  */
 typedef enum {
     LYSC_PATH_LOG,  /**< Descriptive path format used in log messages */
-    LYSC_PATH_DATA  /**< Similar to ::LYSC_PATH_LOG except that schema-only nodes (choice, case) are skipped */
+    LYSC_PATH_DATA, /**< Similar to ::LYSC_PATH_LOG except that schema-only nodes (choice, case) are skipped */
+    LYSC_PATH_DATA_PATTERN  /**< Similar to ::LYSC_PATH_DATA but there are predicates for all list keys added with
+                                 "%s" where their values should be so that they can be printed there */
 } LYSC_PATH_TYPE;
 
 /**
diff --git a/src/tree_schema_free.c b/src/tree_schema_free.c
index 561226c..07f32cb 100644
--- a/src/tree_schema_free.c
+++ b/src/tree_schema_free.c
@@ -618,8 +618,9 @@
     const struct lysp_submodule *submod;
     const struct lysp_module *base_pmod = NULL;
     const struct lysp_ident *identp = NULL;
-    const struct lys_module *mod;
+    const struct lys_module *mod, *iter;
     const char *base_name;
+    uint32_t i;
 
     /* find the parsed identity */
     LY_ARRAY_FOR(ident->module->parsed->identities, u) {
@@ -658,6 +659,17 @@
         }
         ++base_name;
 
+        i = 0;
+        while ((iter = ly_ctx_get_module_iter(ident->module->ctx, &i))) {
+            if (iter == mod) {
+                break;
+            }
+        }
+        if (!iter) {
+            /* target module was freed already */
+            continue;
+        }
+
         /* find the compiled base */
         LY_ARRAY_FOR(mod->identities, v) {
             if (!strcmp(mod->identities[v].name, base_name)) {
@@ -666,7 +678,10 @@
                     if (mod->identities[v].derived[w] == ident) {
                         /* remove the link */
                         LY_ARRAY_DECREMENT(mod->identities[v].derived);
-                        if (w < LY_ARRAY_COUNT(mod->identities[v].derived)) {
+                        if (!LY_ARRAY_COUNT(mod->identities[v].derived)) {
+                            LY_ARRAY_FREE(mod->identities[v].derived);
+                            mod->identities[v].derived = NULL;
+                        } else if (w < LY_ARRAY_COUNT(mod->identities[v].derived)) {
                             memmove(mod->identities[v].derived + w, mod->identities[v].derived + w + 1,
                                     (LY_ARRAY_COUNT(mod->identities[v].derived) - w) * sizeof ident);
                         }
diff --git a/src/validation.c b/src/validation.c
index 8004b44..bc68558 100644
--- a/src/validation.c
+++ b/src/validation.c
@@ -275,11 +275,11 @@
             struct lyd_ctx_ext_val *ext_v = ext_val->objs[i];
 
             /* validate extension data */
-            ret = ext_v->ext->def->plugin->validate(ext_v->ext, ext_v->sibling, val_opts);
+            ret = ext_v->ext->def->plugin->validate(ext_v->ext, ext_v->sibling, val_opts, diff);
             LY_CHECK_RET(ret);
 
             /* remove this item from the set */
-            ly_set_rm_index(node_types, i, free);
+            ly_set_rm_index(ext_val, i, free);
         } while (i);
     }
 
diff --git a/src/xpath.c b/src/xpath.c
index 64b9ef8..e45b489 100644
--- a/src/xpath.c
+++ b/src/xpath.c
@@ -1216,9 +1216,9 @@
         if (set->used == set->size) {
 
             /* set is full */
-            set->val.nodes = ly_realloc(set->val.nodes, (set->size + LYXP_SET_SIZE_STEP) * sizeof *set->val.nodes);
+            set->val.nodes = ly_realloc(set->val.nodes, (set->size * LYXP_SET_SIZE_MUL_STEP) * sizeof *set->val.nodes);
             LY_CHECK_ERR_RET(!set->val.nodes, LOGMEM(set->ctx), );
-            set->size += LYXP_SET_SIZE_STEP;
+            set->size *= LYXP_SET_SIZE_MUL_STEP;
         }
 
         if (idx > set->used) {
@@ -1250,13 +1250,25 @@
 
     assert(set->type == LYXP_SET_SCNODE_SET);
 
+    if (!set->size) {
+        /* first item */
+        set->val.scnodes = malloc(LYXP_SET_SIZE_START * sizeof *set->val.scnodes);
+        LY_CHECK_ERR_RET(!set->val.scnodes, LOGMEM(set->ctx), LY_EMEM);
+        set->type = LYXP_SET_SCNODE_SET;
+        set->used = 0;
+        set->size = LYXP_SET_SIZE_START;
+        set->ctx_pos = 1;
+        set->ctx_size = 1;
+        set->ht = NULL;
+    }
+
     if (lyxp_set_scnode_contains(set, node, node_type, -1, &index)) {
         set->val.scnodes[index].in_ctx = LYXP_SET_SCNODE_ATOM_CTX;
     } else {
         if (set->used == set->size) {
-            set->val.scnodes = ly_realloc(set->val.scnodes, (set->size + LYXP_SET_SIZE_STEP) * sizeof *set->val.scnodes);
+            set->val.scnodes = ly_realloc(set->val.scnodes, (set->size * LYXP_SET_SIZE_MUL_STEP) * sizeof *set->val.scnodes);
             LY_CHECK_ERR_RET(!set->val.scnodes, LOGMEM(set->ctx), LY_EMEM);
-            set->size += LYXP_SET_SIZE_STEP;
+            set->size *= LYXP_SET_SIZE_MUL_STEP;
         }
 
         index = set->used;
diff --git a/src/xpath.h b/src/xpath.h
index fd8948e..e24f157 100644
--- a/src/xpath.h
+++ b/src/xpath.h
@@ -83,8 +83,8 @@
 #define LYXP_EXPR_SIZE_STEP 5
 
 /* XPath matches allocation */
-#define LYXP_SET_SIZE_START 2
-#define LYXP_SET_SIZE_STEP 2
+#define LYXP_SET_SIZE_START 4
+#define LYXP_SET_SIZE_MUL_STEP 2
 
 /* building string when casting */
 #define LYXP_STRING_CAST_SIZE_START 64
diff --git a/tests/plugins/simple.c b/tests/plugins/simple.c
index f74147d..fdd3fb3 100644
--- a/tests/plugins/simple.c
+++ b/tests/plugins/simple.c
@@ -54,7 +54,7 @@
         .plugin.compile = &hint_compile,
         .plugin.sprinter = NULL,
         .plugin.free = NULL,
-        .plugin.parse = NULL,
+        .plugin.snode = NULL,
         .plugin.validate = NULL
     },
     {0} /* terminating zeroed item */
diff --git a/tests/utests/data/test_new.c b/tests/utests/data/test_new.c
index 8fe2816..4ebc92f 100644
--- a/tests/utests/data/test_new.c
+++ b/tests/utests/data/test_new.c
@@ -147,10 +147,10 @@
     lyd_free_tree(node);
 
     assert_int_equal(lyd_new_inner(NULL, mod, "l1", 0, &node), LY_ENOTFOUND);
-    CHECK_LOG_CTX("Inner node (not a list) \"l1\" not found.", NULL);
+    CHECK_LOG_CTX("Inner node (container, notif, RPC, or action) \"l1\" not found.", NULL);
 
     assert_int_equal(lyd_new_inner(NULL, mod, "l2", 0, &node), LY_ENOTFOUND);
-    CHECK_LOG_CTX("Inner node (not a list) \"l2\" not found.", NULL);
+    CHECK_LOG_CTX("Inner node (container, notif, RPC, or action) \"l2\" not found.", NULL);
 
     /* anydata */
     assert_int_equal(lyd_new_any(NULL, mod, "any", "some-value", 0, LYD_ANYDATA_STRING, 0, &node), LY_SUCCESS);
diff --git a/tests/utests/data/test_parser_json.c b/tests/utests/data/test_parser_json.c
index a9c537f..4682dcf 100644
--- a/tests/utests/data/test_parser_json.c
+++ b/tests/utests/data/test_parser_json.c
@@ -172,6 +172,11 @@
     CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
     lyd_free_all(tree);
 
+    /* accept empty */
+    data = "{\"a:ll1\":[]}";
+    CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree);
+    assert_null(tree);
+
     /* simple metadata */
     data = "{\"a:ll1\":[10,11],\"@a:ll1\":[null,{\"a:hint\":2}]}";
     CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree);
@@ -368,10 +373,14 @@
     LY_LIST_FOR(list->child, iter) {
         assert_int_not_equal(0, iter->hash);
     }
-
     CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, data);
     lyd_free_all(tree);
 
+    /* accept empty */
+    data = "{\"a:l1\":[]}";
+    CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree);
+    assert_null(tree);
+
     /* missing keys */
     PARSER_CHECK_ERROR("{ \"a:l1\": [ {\"c\" : 1, \"b\" : \"b\"}]}", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
             "List instance is missing its key \"a\".", "Schema location /a:l1, data location /a:l1[b='b'][c='1'], line number 1.");
diff --git a/tests/utests/extensions/test_schema_mount.c b/tests/utests/extensions/test_schema_mount.c
index 5216274..29117d5 100644
--- a/tests/utests/extensions/test_schema_mount.c
+++ b/tests/utests/extensions/test_schema_mount.c
@@ -462,6 +462,7 @@
 test_parse_inline(void **state)
 {
     const char *xml, *json;
+    char *lyb;
     struct lyd_node *data;
 
     /* valid */
@@ -649,6 +650,12 @@
 
     CHECK_PARSE_LYD_PARAM(json, LYD_JSON, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_SUCCESS, data);
     CHECK_LYD_STRING_PARAM(data, json, LYD_JSON, LYD_PRINT_WITHSIBLINGS);
+
+    assert_int_equal(LY_SUCCESS, lyd_print_mem(&lyb, data, LYD_LYB, 0));
+    lyd_free_siblings(data);
+
+    CHECK_PARSE_LYD_PARAM(lyb, LYD_LYB, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_SUCCESS, data);
+    free(lyb);
     lyd_free_siblings(data);
 }
 
@@ -656,6 +663,7 @@
 test_parse_shared(void **state)
 {
     const char *xml, *json;
+    char *lyb;
     struct lyd_node *data;
 
     ly_ctx_set_ext_data_clb(UTEST_LYCTX, test_ext_data_clb,
@@ -1011,6 +1019,12 @@
             "}\n";
     CHECK_PARSE_LYD_PARAM(json, LYD_JSON, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_SUCCESS, data);
     CHECK_LYD_STRING_PARAM(data, json, LYD_JSON, LYD_PRINT_WITHSIBLINGS);
+
+    assert_int_equal(LY_SUCCESS, lyd_print_mem(&lyb, data, LYD_LYB, LYD_PRINT_WITHSIBLINGS));
+    lyd_free_siblings(data);
+
+    CHECK_PARSE_LYD_PARAM(lyb, LYD_LYB, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_SUCCESS, data);
+    free(lyb);
     lyd_free_siblings(data);
 }
 
@@ -1278,6 +1292,129 @@
     lyd_free_siblings(data);
 }
 
+static void
+test_new(void **state)
+{
+    const char *xml;
+    const struct lys_module *mod;
+    struct lyd_node *data, *node;
+
+    ly_ctx_set_ext_data_clb(UTEST_LYCTX, test_ext_data_clb,
+            "<yang-library xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\" "
+            "    xmlns:ds=\"urn:ietf:params:xml:ns:yang:ietf-datastores\">"
+            "  <module-set>"
+            "    <name>test-set</name>"
+            "    <module>"
+            "      <name>ietf-datastores</name>"
+            "      <revision>2018-02-14</revision>"
+            "      <namespace>urn:ietf:params:xml:ns:yang:ietf-datastores</namespace>"
+            "    </module>"
+            "    <module>"
+            "      <name>ietf-yang-library</name>"
+            "      <revision>2019-01-04</revision>"
+            "      <namespace>urn:ietf:params:xml:ns:yang:ietf-yang-library</namespace>"
+            "    </module>"
+            "    <module>"
+            "      <name>ietf-yang-schema-mount</name>"
+            "      <revision>2019-01-14</revision>"
+            "      <namespace>urn:ietf:params:xml:ns:yang:ietf-yang-schema-mount</namespace>"
+            "    </module>"
+            "    <module>"
+            "      <name>ietf-interfaces</name>"
+            "      <revision>2014-05-08</revision>"
+            "      <namespace>urn:ietf:params:xml:ns:yang:ietf-interfaces</namespace>"
+            "    </module>"
+            "    <module>"
+            "      <name>iana-if-type</name>"
+            "      <revision>2014-05-08</revision>"
+            "      <namespace>urn:ietf:params:xml:ns:yang:iana-if-type</namespace>"
+            "    </module>"
+            "    <import-only-module>"
+            "      <name>ietf-yang-types</name>"
+            "      <revision>2013-07-15</revision>"
+            "      <namespace>urn:ietf:params:xml:ns:yang:ietf-yang-types</namespace>"
+            "    </import-only-module>"
+            "  </module-set>"
+            "  <schema>"
+            "    <name>test-schema</name>"
+            "    <module-set>test-set</module-set>"
+            "  </schema>"
+            "  <datastore>"
+            "    <name>ds:running</name>"
+            "    <schema>test-schema</schema>"
+            "  </datastore>"
+            "  <datastore>"
+            "    <name>ds:operational</name>"
+            "    <schema>test-schema</schema>"
+            "  </datastore>"
+            "  <content-id>1</content-id>"
+            "</yang-library>"
+            "<modules-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-library\">"
+            "  <module-set-id>1</module-set-id>"
+            "</modules-state>"
+            "<schema-mounts xmlns=\"urn:ietf:params:xml:ns:yang:ietf-yang-schema-mount\">"
+            "  <mount-point>"
+            "    <module>sm</module>"
+            "    <label>root</label>"
+            "    <shared-schema/>"
+            "  </mount-point>"
+            "</schema-mounts>");
+    xml =
+            "<root xmlns=\"urn:sm\">\n"
+            "  <interfaces xmlns=\"urn:ietf:params:xml:ns:yang:ietf-interfaces\">\n"
+            "    <interface>\n"
+            "      <name>bu</name>\n"
+            "      <type xmlns:ianaift=\"urn:ietf:params:xml:ns:yang:iana-if-type\">ianaift:ethernetCsmacd</type>\n"
+            "    </interface>\n"
+            "  </interfaces>\n"
+            "  <interfaces-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-interfaces\">\n"
+            "    <interface>\n"
+            "      <name>bu</name>\n"
+            "      <type xmlns:ianaift=\"urn:ietf:params:xml:ns:yang:iana-if-type\">ianaift:ethernetCsmacd</type>\n"
+            "      <oper-status>not-present</oper-status>\n"
+            "      <statistics>\n"
+            "        <discontinuity-time>2022-01-01T10:00:00-00:00</discontinuity-time>\n"
+            "      </statistics>\n"
+            "    </interface>\n"
+            "  </interfaces-state>\n"
+            "</root>\n";
+
+    /* create the data manually with simple new functions */
+    mod = ly_ctx_get_module_implemented(UTEST_LYCTX, "sm");
+    assert_non_null(mod);
+    assert_int_equal(LY_SUCCESS, lyd_new_inner(NULL, mod, "root", 0, &data));
+
+    mod = ly_ctx_get_module_implemented(UTEST_LYCTX, "ietf-interfaces");
+    assert_non_null(mod);
+    assert_int_equal(LY_SUCCESS, lyd_new_inner(data, mod, "interfaces", 0, &node));
+    assert_int_equal(LY_SUCCESS, lyd_new_list(node, NULL, "interface", 0, &node, "bu"));
+    assert_int_equal(LY_SUCCESS, lyd_new_term(node, NULL, "type", "iana-if-type:ethernetCsmacd", 0, NULL));
+
+    assert_int_equal(LY_SUCCESS, lyd_new_inner(data, mod, "interfaces-state", 0, &node));
+    assert_int_equal(LY_SUCCESS, lyd_new_list(node, NULL, "interface", 0, &node, "bu"));
+    assert_int_equal(LY_SUCCESS, lyd_new_term(node, NULL, "type", "iana-if-type:ethernetCsmacd", 0, NULL));
+    assert_int_equal(LY_SUCCESS, lyd_new_term(node, NULL, "oper-status", "not-present", 0, NULL));
+    assert_int_equal(LY_SUCCESS, lyd_new_inner(node, NULL, "statistics", 0, &node));
+    assert_int_equal(LY_SUCCESS, lyd_new_term(node, NULL, "discontinuity-time", "2022-01-01T10:00:00-00:00", 0, NULL));
+
+    CHECK_LYD_STRING_PARAM(data, xml, LYD_XML, LYD_PRINT_WITHSIBLINGS);
+    lyd_free_siblings(data);
+
+    /* create the data using lyd_new_path */
+    assert_int_equal(LY_SUCCESS, lyd_new_path(NULL, UTEST_LYCTX,
+            "/sm:root/ietf-interfaces:interfaces/interface[name='bu']/type", "iana-if-type:ethernetCsmacd", 0, &data));
+    assert_int_equal(LY_SUCCESS, lyd_new_path(data, NULL,
+            "/sm:root/ietf-interfaces:interfaces-state/interface[name='bu']/type", "iana-if-type:ethernetCsmacd", 0, NULL));
+    assert_int_equal(LY_SUCCESS, lyd_new_path(data, NULL,
+            "/sm:root/ietf-interfaces:interfaces-state/interface[name='bu']/oper-status", "not-present", 0, NULL));
+    assert_int_equal(LY_SUCCESS, lyd_new_path(data, NULL,
+            "/sm:root/ietf-interfaces:interfaces-state/interface[name='bu']/statistics/discontinuity-time",
+            "2022-01-01T10:00:00-00:00", 0, NULL));
+
+    CHECK_LYD_STRING_PARAM(data, xml, LYD_XML, LYD_PRINT_WITHSIBLINGS);
+    lyd_free_siblings(data);
+}
+
 int
 main(void)
 {
@@ -1288,6 +1425,7 @@
         UTEST(test_parse_shared, setup),
         UTEST(test_parse_shared_parent_ref, setup),
         UTEST(test_parse_config, setup),
+        UTEST(test_new, setup),
     };
 
     return cmocka_run_group_tests(tests, NULL, NULL);
diff --git a/tests/utests/extensions/test_yangdata.c b/tests/utests/extensions/test_yangdata.c
index e9486d2..e7e7bc1 100644
--- a/tests/utests/extensions/test_yangdata.c
+++ b/tests/utests/extensions/test_yangdata.c
@@ -234,7 +234,7 @@
 }
 
 static void
-test_data(void **state)
+test_parse(void **state)
 {
     struct lys_module *mod;
     struct lysc_ext_instance *e;
@@ -266,7 +266,7 @@
     const struct CMUnitTest tests[] = {
         UTEST(test_schema, setup),
         UTEST(test_schema_invalid, setup),
-        UTEST(test_data, setup),
+        UTEST(test_parse, setup),
     };
 
     return cmocka_run_group_tests(tests, NULL, NULL);
diff --git a/tests/utests/utests.h b/tests/utests/utests.h
index 7e85a66..2a5e8a2 100644
--- a/tests/utests/utests.h
+++ b/tests/utests/utests.h
@@ -140,11 +140,6 @@
                 fail_msg("%s != 0x%d", #RET, _r); \
             } \
         } \
-        if (RET == LY_SUCCESS) { \
-            assert_non_null(OUT_NODE); \
-        } else { \
-            assert_null(OUT_NODE); \
-        } \
     }
 
 /**
diff --git a/tools/lint/cmd_data.c b/tools/lint/cmd_data.c
index 919c45e..cd023dc 100644
--- a/tools/lint/cmd_data.c
+++ b/tools/lint/cmd_data.c
@@ -316,9 +316,8 @@
     }
 
     /* parse, validate and print data */
-    if (process_data(*ctx, data_type, data_merge, outformat, out,
-            options_parse, options_validate, options_print,
-            operational, &inputs, &xpaths)) {
+    if (process_data(*ctx, data_type, data_merge, outformat, out, options_parse, options_validate, options_print,
+            operational, NULL, &inputs, &xpaths)) {
         goto cleanup;
     }
 
diff --git a/tools/lint/common.c b/tools/lint/common.c
index b41e4fe..8819443 100644
--- a/tools/lint/common.c
+++ b/tools/lint/common.c
@@ -443,16 +443,15 @@
 
 LY_ERR
 process_data(struct ly_ctx *ctx, enum lyd_type data_type, uint8_t merge, LYD_FORMAT format, struct ly_out *out,
-        uint32_t options_parse, uint32_t options_validate, uint32_t options_print,
-        struct cmdline_file *operational_f, struct ly_set *inputs, struct ly_set *xpaths)
+        uint32_t options_parse, uint32_t options_validate, uint32_t options_print, struct cmdline_file *operational_f,
+        struct cmdline_file *rpc_f, struct ly_set *inputs, struct ly_set *xpaths)
 {
     LY_ERR ret = LY_SUCCESS;
-    struct lyd_node *tree = NULL, *merged_tree = NULL;
-    struct lyd_node *operational = NULL;
+    struct lyd_node *tree = NULL, *envp = NULL, *merged_tree = NULL, *oper_tree = NULL;
 
     /* additional operational datastore */
     if (operational_f && operational_f->in) {
-        ret = lyd_parse_data(ctx, NULL, operational_f->in, operational_f->format, LYD_PARSE_ONLY, 0, &operational);
+        ret = lyd_parse_data(ctx, NULL, operational_f->in, operational_f->format, LYD_PARSE_ONLY, 0, &oper_tree);
         if (ret) {
             YLMSG_E("Failed to parse operational datastore file \"%s\".\n", operational_f->path);
             goto cleanup;
@@ -470,6 +469,28 @@
         case LYD_TYPE_NOTIF_YANG:
             ret = lyd_parse_op(ctx, NULL, input_f->in, input_f->format, data_type, &tree, NULL);
             break;
+        case LYD_TYPE_RPC_NETCONF:
+        case LYD_TYPE_NOTIF_NETCONF:
+            ret = lyd_parse_op(ctx, NULL, input_f->in, input_f->format, data_type, &envp, &tree);
+            break;
+        case LYD_TYPE_REPLY_NETCONF:
+            /* parse source RPC operation */
+            assert(rpc_f && rpc_f->in);
+            ret = lyd_parse_op(ctx, NULL, rpc_f->in, rpc_f->format, LYD_TYPE_RPC_NETCONF, &envp, &tree);
+            if (ret) {
+                YLMSG_E("Failed to parse source NETCONF RPC operation file \"%s\".\n", rpc_f->path);
+                goto cleanup;
+            }
+
+            /* free input */
+            lyd_free_siblings(lyd_child(tree));
+
+            /* we do not care */
+            lyd_free_all(envp);
+            envp = NULL;
+
+            ret = lyd_parse_op(ctx, tree, input_f->in, input_f->format, data_type, &envp, NULL);
+            break;
         default:
             YLMSG_E("Internal error (%s:%d).\n", __FILE__, __LINE__);
             goto cleanup;
@@ -493,18 +514,40 @@
             }
             tree = NULL;
         } else if (format) {
-            lyd_print_all(out, tree, format, options_print);
-        } else if (operational) {
+            /* print */
+            switch (data_type) {
+            case LYD_TYPE_DATA_YANG:
+                lyd_print_all(out, tree, format, options_print);
+                break;
+            case LYD_TYPE_RPC_YANG:
+            case LYD_TYPE_REPLY_YANG:
+            case LYD_TYPE_NOTIF_YANG:
+            case LYD_TYPE_RPC_NETCONF:
+            case LYD_TYPE_NOTIF_NETCONF:
+                lyd_print_tree(out, tree, format, options_print);
+                break;
+            case LYD_TYPE_REPLY_NETCONF:
+                /* just the output */
+                lyd_print_tree(out, lyd_child(tree), format, options_print);
+                break;
+            default:
+                assert(0);
+            }
+        } else if (oper_tree) {
             /* additional validation of the RPC/Action/reply/Notification with the operational datastore */
-            ret = lyd_validate_op(tree, operational, data_type, NULL);
+            ret = lyd_validate_op(tree, oper_tree, data_type, NULL);
             if (ret) {
                 YLMSG_E("Failed to validate input data file \"%s\" with operational datastore \"%s\".\n",
                         input_f->path, operational_f->path);
                 goto cleanup;
             }
         }
+
+        /* next iter */
         lyd_free_all(tree);
         tree = NULL;
+        lyd_free_all(envp);
+        envp = NULL;
     }
 
     if (merge) {
@@ -520,7 +563,7 @@
             lyd_print_all(out, merged_tree, format, options_print);
         }
 
-        for (uint32_t u = 0; u < xpaths->count; ++u) {
+        for (uint32_t u = 0; xpaths && (u < xpaths->count); ++u) {
             if (evaluate_xpath(merged_tree, (const char *)xpaths->objs[u])) {
                 goto cleanup;
             }
@@ -528,9 +571,9 @@
     }
 
 cleanup:
-    /* cleanup */
-    lyd_free_all(merged_tree);
     lyd_free_all(tree);
-
+    lyd_free_all(envp);
+    lyd_free_all(merged_tree);
+    lyd_free_all(oper_tree);
     return ret;
 }
diff --git a/tools/lint/common.h b/tools/lint/common.h
index ae37df2..0bc93c8 100644
--- a/tools/lint/common.h
+++ b/tools/lint/common.h
@@ -187,13 +187,14 @@
  * @param[in] options_print Printer options.
  * @param[in] operational_f Optional operational datastore file information for the case of an extended validation of
  * operation(s).
+ * @param[in] rpc_f Source RPC operation file information for parsing NETCONF rpc-reply.
  * @param[in] inputs Set of file informations of input data files.
  * @param[in] xpath The set of XPaths to be evaluated on the processed data tree, basic information about the resulting set
  * is printed. Alternative to data printing.
- * return LY_ERR value.
+ * @return LY_ERR value.
  */
 LY_ERR process_data(struct ly_ctx *ctx, enum lyd_type data_type, uint8_t merge, LYD_FORMAT format, struct ly_out *out,
-        uint32_t options_parse, uint32_t options_validate, uint32_t options_print,
-        struct cmdline_file *operational_f, struct ly_set *inputs, struct ly_set *xpaths);
+        uint32_t options_parse, uint32_t options_validate, uint32_t options_print, struct cmdline_file *operational_f,
+        struct cmdline_file *rpc_f, struct ly_set *inputs, struct ly_set *xpaths);
 
 #endif /* COMMON_H_ */
diff --git a/tools/lint/main_ni.c b/tools/lint/main_ni.c
index 39e2694..5ff8a69 100644
--- a/tools/lint/main_ni.c
+++ b/tools/lint/main_ni.c
@@ -90,6 +90,9 @@
 
     /* storage for --operational */
     struct cmdline_file data_operational;
+
+    /* storage for --reply-rpc */
+    struct cmdline_file reply_rpc;
 };
 
 static void
@@ -120,11 +123,19 @@
 help(int shortout)
 {
 
-    printf("Usage:\n"
-            "    yanglint [Options] [-f { yang | yin | info}] <schema>...\n"
-            "        Validates the YANG module in <schema>, and all its dependencies.\n\n"
-            "    yanglint [Options] [-f { xml | json }] <schema>... <file> ...\n"
-            "        Validates the YANG modeled data in <file> according to the <schema>.\n\n"
+    printf("Example usage:\n"
+            "    yanglint [-f { yang | yin | info}] <schema>...\n"
+            "        Validates the YANG module <schema>(s) and all its dependencies, optionally printing\n"
+            "        them in the specified format.\n\n"
+            "    yanglint [-f { xml | json }] <schema>... <file>...\n"
+            "        Validates the YANG modeled data <file>(s) according to the <schema>(s) optionally\n"
+            "        printing them in the specified format.\n\n"
+            "    yanglint -t (nc-)rpc/notif [-O <operational-file>] <schema>... <file>\n"
+            "        Validates the YANG/NETCONF RPC/notification <file> according to the <schema>(s) using\n"
+            "        <operational-file> with possible references to the operational datastore data.\n\n"
+            "    yanglint -t nc-reply -R <rpc-file> [-O <operational-file>] <schema>... <file>\n"
+            "        Validates the NETCONF rpc-reply <file> of RPC <rpc-file> according to the <schema>(s)\n"
+            "        using <operational-file> with possible references to the operational datastore data.\n\n"
             "    yanglint\n"
             "        Starts interactive mode with more features.\n\n");
 
@@ -142,7 +153,7 @@
     printf("  -f FORMAT, --format=FORMAT\n"
             "                Convert input into FORMAT. Supported formats: \n"
             "                yang, yin, tree and info for schemas,\n"
-            "                xml, json for data.\n\n");
+            "                xml, json, and lyb for data.\n\n");
 
     printf("  -p PATH, --path=PATH\n"
             "                Search path for schema (YANG/YIN) modules. The option can be\n"
@@ -193,17 +204,23 @@
             "                Specify data tree type in the input data file(s):\n"
             "        data          - Complete datastore with status data (default type).\n"
             "        config        - Configuration datastore (without status data).\n"
-            "        get           - Result of the NETCONF <get> operation.\n"
-            "        getconfig     - Result of the NETCONF <get-config> operation.\n"
-            "        edit          - Content of the NETCONF <edit-config> operation.\n"
-            "        rpc           - Content of the NETCONF <rpc> message, defined as YANG's\n"
-            "                        RPC/Action input statement.\n"
-            "        reply         - Reply to the RPC/Action. Note that the reply data are\n"
-            "                        expected inside a container representing the original\n"
-            "                        RPC/Action. This is necessary to identify appropriate\n"
-            "                        data definitions in the schema module.\n"
-            "        notif         - Notification instance (content of the <notification>\n"
-            "                        element without <eventTime>).\n\n");
+            "        get           - Data returned by the NETCONF <get> operation.\n"
+            "        getconfig     - Data returned by the NETCONF <get-config> operation.\n"
+            "        edit          - Config content of the NETCONF <edit-config> operation.\n"
+            "        rpc           - Invocation of a YANG RPC/action, defined as input.\n"
+            "        nc-rpc        - Similar to 'rpc' but expect and check also the NETCONF\n"
+            "                        envelopes <rpc> or <action>.\n"
+            "        reply         - Reply to a YANG RPC/action, defined as output. Note that\n"
+            "                        the reply data are expected inside a container representing\n"
+            "                        the original RPC/action invocation.\n"
+            "        nc-reply      - Similar to 'reply' but expect and check also the NETCONF\n"
+            "                        envelope <rpc-reply> with output data nodes as direct\n"
+            "                        descendants. The original RPC/action invocation is expected\n"
+            "                        in a separate parameter '-R' and is parsed as 'nc-rpc'.\n"
+            "        notif         - Notification instance of a YANG notification.\n"
+            "        nc-notif      - Similar to 'notif' but expect and check also the NETCONF\n"
+            "                        envelope <notification> with element <eventTime> and its\n"
+            "                        sibling as the actual notification.\n\n");
 
     printf("  -d MODE, --default=MODE\n"
             "                Print data with default values, according to the MODE\n"
@@ -233,8 +250,12 @@
             "                the :running configuration datastore and state data\n"
             "                (operational datastore) referenced from the RPC/Notification.\n\n");
 
+    printf("  -R FILE, --reply-rpc=FILE\n"
+            "                Provide source RPC for parsing of the 'nc-reply' TYPE. The FILE\n"
+            "                is supposed to contain the source 'nc-rpc' operation of the reply.\n\n");
+
     printf("  -m, --merge   Merge input data files into a single tree and validate at\n"
-            "                once.The option has effect only for 'data' and 'config' TYPEs.\n\n");
+            "                once. The option has effect only for 'data' and 'config' TYPEs.\n\n");
 
     printf("  -y, --yang-library\n"
             "                Load and implement internal \"ietf-yang-library\" YANG module.\n"
@@ -332,12 +353,17 @@
         }
     }
 
-    /* process the operational content if any */
+    /* process the operational and/or reply RPC content if any */
     if (c->data_operational.path) {
         if (get_input(c->data_operational.path, NULL, &c->data_operational.format, &c->data_operational.in)) {
             return -1;
         }
     }
+    if (c->reply_rpc.path) {
+        if (get_input(c->reply_rpc.path, NULL, &c->reply_rpc.format, &c->reply_rpc.in)) {
+            return -1;
+        }
+    }
 
     for (int i = 0; i < argc - optind; i++) {
         LYS_INFORMAT format_schema = LYS_IN_UNKNOWN;
@@ -460,7 +486,7 @@
         {"quiet",             no_argument,       NULL, 'Q'},
         {"format",            required_argument, NULL, 'f'},
         {"path",              required_argument, NULL, 'p'},
-        {"disable-searchdir", no_argument,      NULL, 'D'},
+        {"disable-searchdir", no_argument,       NULL, 'D'},
         {"features",          required_argument, NULL, 'F'},
         {"make-implemented",  no_argument,       NULL, 'i'},
         {"schema-node",       required_argument, NULL, 'P'},
@@ -474,6 +500,7 @@
         {"tree-line-length",  required_argument, NULL, 'L'},
         {"output",            required_argument, NULL, 'o'},
         {"operational",       required_argument, NULL, 'O'},
+        {"reply-rpc",         required_argument, NULL, 'R'},
         {"merge",             no_argument,       NULL, 'm'},
         {"yang-library",      no_argument,       NULL, 'y'},
         {"yang-library-file", required_argument, NULL, 'Y'},
@@ -490,9 +517,9 @@
 
     opterr = 0;
 #ifndef NDEBUG
-    while ((opt = getopt_long(argc, argv, "hvVQf:p:DF:iP:qs:net:d:lL:o:OmyY:G:", options, &opt_index)) != -1) {
+    while ((opt = getopt_long(argc, argv, "hvVQf:p:DF:iP:qs:net:d:lL:o:O:R:myY:G:", options, &opt_index)) != -1) {
 #else
-    while ((opt = getopt_long(argc, argv, "hvVQf:p:DF:iP:qs:net:d:lL:o:OmyY:", options, &opt_index)) != -1) {
+    while ((opt = getopt_long(argc, argv, "hvVQf:p:DF:iP:qs:net:d:lL:o:O:R:myY:", options, &opt_index)) != -1) {
 #endif
         switch (opt) {
         case 'h': /* --help */
@@ -543,6 +570,9 @@
             } else if (!strcasecmp(optarg, "json")) {
                 c->schema_out_format = 0;
                 c->data_out_format = LYD_JSON;
+            } else if (!strcasecmp(optarg, "lyb")) {
+                c->schema_out_format = 0;
+                c->data_out_format = LYD_LYB;
             } else {
                 YLMSG_E("Unknown output format %s\n", optarg);
                 help(1);
@@ -632,12 +662,18 @@
                 c->data_parse_options |= LYD_PARSE_ONLY | LYD_PARSE_NO_STATE;
             } else if (!strcasecmp(optarg, "edit")) {
                 c->data_parse_options |= LYD_PARSE_ONLY;
-            } else if (!strcasecmp(optarg, "rpc") || !strcasecmp(optarg, "action")) {
+            } else if (!strcasecmp(optarg, "rpc")) {
                 c->data_type = LYD_TYPE_RPC_YANG;
-            } else if (!strcasecmp(optarg, "reply") || !strcasecmp(optarg, "rpcreply")) {
+            } else if (!strcasecmp(optarg, "nc-rpc")) {
+                c->data_type = LYD_TYPE_RPC_NETCONF;
+            } else if (!strcasecmp(optarg, "reply")) {
                 c->data_type = LYD_TYPE_REPLY_YANG;
-            } else if (!strcasecmp(optarg, "notif") || !strcasecmp(optarg, "notification")) {
+            } else if (!strcasecmp(optarg, "nc-reply")) {
+                c->data_type = LYD_TYPE_REPLY_NETCONF;
+            } else if (!strcasecmp(optarg, "notif")) {
                 c->data_type = LYD_TYPE_NOTIF_YANG;
+            } else if (!strcasecmp(optarg, "nc-notif")) {
+                c->data_type = LYD_TYPE_NOTIF_NETCONF;
             } else if (!strcasecmp(optarg, "data")) {
                 /* default option */
             } else {
@@ -693,6 +729,14 @@
             c->data_operational.path = optarg;
             break;
 
+        case 'R': /* --reply-rpc */
+            if (c->reply_rpc.path) {
+                YLMSG_E("The PRC of the reply (-R) cannot be set multiple times.\n");
+                return -1;
+            }
+            c->reply_rpc.path = optarg;
+            break;
+
         case 'm': /* --merge */
             c->data_merge = 1;
             break;
@@ -759,10 +803,18 @@
     }
 
     if (c->data_operational.path && !c->data_type) {
-        YLMSG_E("Operational datastore takes effect only with RPCs/Actions/Replies/Notifications input data types.\n");
+        YLMSG_E("Operational datastore takes effect only with RPCs/Actions/Replies/Notification input data types.\n");
         c->data_operational.path = NULL;
     }
 
+    if (c->reply_rpc.path && (c->data_type != LYD_TYPE_REPLY_NETCONF)) {
+        YLMSG_E("Source RPC is needed only for NETCONF Reply input data type.\n");
+        c->data_operational.path = NULL;
+    } else if (!c->reply_rpc.path && (c->data_type == LYD_TYPE_REPLY_NETCONF)) {
+        YLMSG_E("Missing source RPC (-R) for NETCONF Reply input data type.\n");
+        return -1;
+    }
+
     if ((c->schema_out_format != LYS_OUT_TREE) && c->line_length) {
         YLMSG_E("--tree-line-length take effect only in case of the tree output format.\n");
     }
@@ -877,9 +929,9 @@
 
         /* do the data validation despite the schema was printed */
         if (c.data_inputs.size) {
-            if (process_data(c.ctx, c.data_type, c.data_merge, c.data_out_format, c.out,
-                    c.data_parse_options, c.data_validate_options, c.data_print_options,
-                    &c.data_operational, &c.data_inputs, NULL)) {
+            ret = process_data(c.ctx, c.data_type, c.data_merge, c.data_out_format, c.out, c.data_parse_options,
+                    c.data_validate_options, c.data_print_options, &c.data_operational, &c.reply_rpc, &c.data_inputs, NULL);
+            if (ret) {
                 goto cleanup;
             }
         }
diff --git a/uncrustify_0.74.0.cfg b/uncrustify_0.74.0.cfg
new file mode 100644
index 0000000..764d865
--- /dev/null
+++ b/uncrustify_0.74.0.cfg
@@ -0,0 +1,3349 @@
+# Uncrustify-0.71.0_f
+
+#
+# General options
+#
+
+# Added specific file extensions.
+file_ext C .c.in
+file_ext C-Header .h.in
+
+# The type of line endings.
+#
+# Default: auto
+newlines                        = lf       # lf/crlf/cr/auto
+
+# The original size of tabs in the input.
+#
+# Default: 8
+input_tab_size                  = 8        # unsigned number
+
+# The size of tabs in the output (only used if align_with_tabs=true).
+#
+# Default: 8
+output_tab_size                 = 8        # unsigned number
+
+# The ASCII value of the string escape char, usually 92 (\) or (Pawn) 94 (^).
+#
+# Default: 92
+string_escape_char              = 92       # unsigned number
+
+# Alternate string escape char (usually only used for Pawn).
+# Only works right before the quote char.
+string_escape_char2             = 0        # unsigned number
+
+# Replace tab characters found in string literals with the escape sequence \t
+# instead.
+string_replace_tab_chars        = true     # true/false
+
+# Allow interpreting '>=' and '>>=' as part of a template in code like
+# 'void f(list<list<B>>=val);'. If true, 'assert(x<0 && y>=3)' will be broken.
+# Improvements to template detection may make this option obsolete.
+tok_split_gte                   = false    # true/false
+
+# Disable formatting of NL_CONT ('\\n') ended lines (e.g. multiline macros)
+disable_processing_nl_cont      = false    # true/false
+
+# Specify the marker used in comments to disable processing of part of the
+# file.
+# The comment should be used alone in one line.
+#
+# Default:  *INDENT-OFF*
+disable_processing_cmt          = " *INDENT-OFF*"      # string
+
+# Specify the marker used in comments to (re)enable processing in a file.
+# The comment should be used alone in one line.
+#
+# Default:  *INDENT-ON*
+enable_processing_cmt           = " *INDENT-ON*"     # string
+
+# Enable parsing of digraphs.
+enable_digraphs                 = false    # true/false
+
+# Option to allow both disable_processing_cmt and enable_processing_cmt
+# strings, if specified, to be interpreted as ECMAScript regular expressions.
+# If true, a regex search will be performed within comments according to the
+# specified patterns in order to disable/enable processing.
+processing_cmt_as_regex         = false    # true/false
+
+# Add or remove the UTF-8 BOM (recommend 'remove').
+utf8_bom                        = ignore   # ignore/add/remove/force
+
+# If the file contains bytes with values between 128 and 255, but is not
+# UTF-8, then output as UTF-8.
+utf8_byte                       = false    # true/false
+
+# Force the output encoding to UTF-8.
+utf8_force                      = true     # true/false
+
+# Add or remove space between 'do' and '{'.
+sp_do_brace_open                = force     # ignore/add/remove/force
+
+# Add or remove space between '}' and 'while'.
+sp_brace_close_while            = force     # ignore/add/remove/force
+
+# Add or remove space between 'while' and '('.
+sp_while_paren_open             = force     # ignore/add/remove/force
+
+#
+# Spacing options
+#
+
+# Add or remove space around non-assignment symbolic operators ('+', '/', '%',
+# '<<', and so forth).
+sp_arith                        = force     # ignore/add/remove/force
+
+# Add or remove space around arithmetic operators '+' and '-'.
+#
+# Overrides sp_arith.
+sp_arith_additive               = force     # ignore/add/remove/force
+
+# Add or remove space around assignment operator '=', '+=', etc.
+sp_assign                       = force     # ignore/add/remove/force
+
+# Add or remove space around '=' in C++11 lambda capture specifications.
+#
+# Overrides sp_assign.
+sp_cpp_lambda_assign            = force    # ignore/add/remove/force
+
+# Add or remove space after the capture specification of a C++11 lambda when
+# an argument list is present, as in '[] <here> (int x){ ... }'.
+sp_cpp_lambda_square_paren      = ignore   # ignore/add/remove/force
+
+# Add or remove space after the capture specification of a C++11 lambda with
+# no argument list is present, as in '[] <here> { ... }'.
+sp_cpp_lambda_square_brace      = ignore   # ignore/add/remove/force
+
+# Add or remove space after the opening parenthesis and before the closing
+# parenthesis of a argument list of a C++11 lambda, as in
+# '[]( <here> int x <here> ){ ... }'.
+sp_cpp_lambda_argument_list     = ignore   # ignore/add/remove/force/not_defined
+
+# Add or remove space after the argument list of a C++11 lambda, as in
+# '[](int x) <here> { ... }'.
+sp_cpp_lambda_paren_brace       = ignore   # ignore/add/remove/force
+
+# Add or remove space between a lambda body and its call operator of an
+# immediately invoked lambda, as in '[]( ... ){ ... } <here> ( ... )'.
+sp_cpp_lambda_fparen            = ignore   # ignore/add/remove/force
+
+# Add or remove space around assignment operator '=' in a prototype.
+#
+# If set to ignore, use sp_assign.
+sp_assign_default               = ignore   # ignore/add/remove/force
+
+# Add or remove space before assignment operator '=', '+=', etc.
+#
+# Overrides sp_assign.
+sp_before_assign                = force    # ignore/add/remove/force
+
+# Add or remove space after assignment operator '=', '+=', etc.
+#
+# Overrides sp_assign.
+sp_after_assign                 = force    # ignore/add/remove/force
+
+# Add or remove space in 'NS_ENUM ('.
+sp_enum_paren                   = force    # ignore/add/remove/force
+
+# Add or remove space around assignment '=' in enum.
+sp_enum_assign                  = force    # ignore/add/remove/force
+
+# Add or remove space before assignment '=' in enum.
+#
+# Overrides sp_enum_assign.
+sp_enum_before_assign           = force    # ignore/add/remove/force
+
+# Add or remove space after assignment '=' in enum.
+#
+# Overrides sp_enum_assign.
+sp_enum_after_assign            = force    # ignore/add/remove/force
+
+# Add or remove space around assignment ':' in enum.
+sp_enum_colon                   = ignore    # ignore/add/remove/force
+
+# Add or remove space around preprocessor '##' concatenation operator.
+#
+# Default: add
+sp_pp_concat                    = ignore    # ignore/add/remove/force
+
+# Add or remove space after preprocessor '#' stringify operator.
+# Also affects the '#@' charizing operator.
+sp_pp_stringify                 = ignore    # ignore/add/remove/force
+
+# Add or remove space before preprocessor '#' stringify operator
+# as in '#define x(y) L#y'.
+sp_before_pp_stringify          = ignore    # ignore/add/remove/force
+
+# Add or remove space around boolean operators '&&' and '||'.
+sp_bool                         = force     # ignore/add/remove/force
+
+# Add or remove space around compare operator '<', '>', '==', etc.
+sp_compare                      = force     # ignore/add/remove/force
+
+# Add or remove space inside '(' and ')'.
+sp_inside_paren                 = remove    # ignore/add/remove/force
+
+# Add or remove space between nested parentheses, i.e. '((' vs. ') )'.
+sp_paren_paren                  = remove    # ignore/add/remove/force
+
+# Add or remove space between back-to-back parentheses, i.e. ')(' vs. ') ('.
+sp_cparen_oparen                = remove    # ignore/add/remove/force
+
+# Whether to balance spaces inside nested parentheses.
+sp_balance_nested_parens        = false     # true/false
+
+# Add or remove space between ')' and '{'.
+sp_paren_brace                  = force     # ignore/add/remove/force
+
+# Add or remove space between nested braces, i.e. '{{' vs '{ {'.
+sp_brace_brace                  = ignore    # ignore/add/remove/force
+
+# Add or remove space before pointer star '*'.
+sp_before_ptr_star              = force    # ignore/add/remove/force
+
+# Add or remove space before pointer star '*' that isn't followed by a
+# variable name. If set to ignore, sp_before_ptr_star is used instead.
+sp_before_unnamed_ptr_star      = ignore   # ignore/add/remove/force
+
+# Add or remove space between pointer stars '*'.
+sp_between_ptr_star             = remove   # ignore/add/remove/force
+
+# Add or remove space after pointer star '*', if followed by a word.
+#
+# Overrides sp_type_func.
+sp_after_ptr_star               = remove   # ignore/add/remove/force
+
+# Add or remove space after pointer caret '^', if followed by a word.
+#sp_after_ptr_block_caret        = ignore   # ignore/add/remove/force
+
+# Add or remove space after pointer star '*', if followed by a qualifier.
+sp_after_ptr_star_qualifier     = force    # ignore/add/remove/force
+
+# Add or remove space after a pointer star '*', if followed by a function
+# prototype or function definition.
+#
+# Overrides sp_after_ptr_star and sp_type_func.
+sp_after_ptr_star_func          = ignore   # ignore/add/remove/force
+
+# Add or remove space after a pointer star '*' in the trailing return of a
+# function prototype or function definition.
+sp_after_ptr_star_trailing      = ignore   # ignore/add/remove/force/not_defined
+
+# Add or remove space between the pointer star '*' and the name of the variable
+# in a function pointer definition.
+sp_ptr_star_func_var            = remove   # ignore/add/remove/force/not_defined
+
+# Add or remove space after a pointer star '*', if followed by an open
+# parenthesis, as in 'void* (*)().
+sp_ptr_star_paren               = remove   # ignore/add/remove/force
+
+# Add or remove space before a pointer star '*', if followed by a function
+# prototype or function definition.
+sp_before_ptr_star_func         = force    # ignore/add/remove/force
+
+# Add or remove space before a pointer star '*' in the trailing return of a
+# function prototype or function definition.
+sp_before_ptr_star_trailing     = ignore   # ignore/add/remove/force/not_defined
+
+# Add or remove space before a reference sign '&'.
+sp_before_byref                 = ignore    # ignore/add/remove/force
+
+# Add or remove space before a reference sign '&' that isn't followed by a
+# variable name. If set to ignore, sp_before_byref is used instead.
+sp_before_unnamed_byref         = ignore   # ignore/add/remove/force
+
+# Add or remove space after reference sign '&', if followed by a word.
+#
+# Overrides sp_type_func.
+sp_after_byref                  = ignore   # ignore/add/remove/force
+
+# Add or remove space after a reference sign '&', if followed by a function
+# prototype or function definition.
+#
+# Overrides sp_after_byref and sp_type_func.
+sp_after_byref_func             = ignore   # ignore/add/remove/force
+
+# Add or remove space before a reference sign '&', if followed by a function
+# prototype or function definition.
+sp_before_byref_func            = ignore    # ignore/add/remove/force
+
+# Add or remove space between type and word.
+#
+# Default: force
+sp_after_type                   = ignore    # ignore/add/remove/force
+
+# Add or remove space between 'decltype(...)' and word.
+sp_after_decltype               = ignore   # ignore/add/remove/force
+
+# (D) Add or remove space before the parenthesis in the D constructs
+# 'template Foo(' and 'class Foo('.
+sp_before_template_paren        = ignore   # ignore/add/remove/force
+
+# Add or remove space between 'template' and '<'.
+# If set to ignore, sp_before_angle is used.
+sp_template_angle               = ignore   # ignore/add/remove/force
+
+# Add or remove space before '<'.
+sp_before_angle                 = ignore   # ignore/add/remove/force
+
+# Add or remove space inside '<' and '>'.
+sp_inside_angle                 = ignore   # ignore/add/remove/force
+
+# Add or remove space inside '<>'.
+sp_inside_angle_empty           = ignore   # ignore/add/remove/force
+
+# Add or remove space between '>' and ':'.
+sp_angle_colon                  = ignore   # ignore/add/remove/force
+
+# Add or remove space after '>'.
+sp_after_angle                  = ignore   # ignore/add/remove/force
+
+# Add or remove space between '>' and '(' as found in 'new List<byte>(foo);'.
+sp_angle_paren                  = ignore   # ignore/add/remove/force
+
+# Add or remove space between '>' and '()' as found in 'new List<byte>();'.
+sp_angle_paren_empty            = ignore   # ignore/add/remove/force
+
+# Add or remove space between '>' and a word as in 'List<byte> m;' or
+# 'template <typename T> static ...'.
+sp_angle_word                   = ignore   # ignore/add/remove/force
+
+# Add or remove space between '>' and '>' in '>>' (template stuff).
+#
+# Default: add
+sp_angle_shift                  = ignore   # ignore/add/remove/force
+
+# (C++11) Permit removal of the space between '>>' in 'foo<bar<int> >'. Note
+# that sp_angle_shift cannot remove the space without this option.
+sp_permit_cpp11_shift           = false    # true/false
+
+# Add or remove space before '(' of control statements ('if', 'for', 'switch',
+# 'while', etc.).
+sp_before_sparen                = force    # ignore/add/remove/force
+
+# Add or remove space inside '(' and ')' of control statements.
+sp_inside_sparen                = remove   # ignore/add/remove/force
+
+# Add or remove space after '(' of control statements.
+#
+# Overrides sp_inside_sparen.
+sp_inside_sparen_open           = ignore   # ignore/add/remove/force
+
+# Add or remove space before ')' of control statements.
+#
+# Overrides sp_inside_sparen.
+sp_inside_sparen_close          = ignore   # ignore/add/remove/force
+
+# Add or remove space inside '(' and ')' of 'for' statements.
+sp_inside_for                   = remove   # ignore/add/remove/force/not_defined
+
+# Add or remove space after '(' of 'for' statements.
+#
+# Overrides sp_inside_for.
+sp_inside_for_open              = ignore   # ignore/add/remove/force/not_defined
+
+# Add or remove space before ')' of 'for' statements.
+#
+# Overrides sp_inside_for.
+sp_inside_for_close             = ignore   # ignore/add/remove/force/not_defined
+
+# Add or remove space between '((' or '))' of control statements.
+sp_sparen_paren                 = ignore   # ignore/add/remove/force/not_defined
+
+# Add or remove space after ')' of control statements.
+sp_after_sparen                 = force    # ignore/add/remove/force
+
+# Add or remove space between ')' and '{' of of control statements.
+sp_sparen_brace                 = force    # ignore/add/remove/force
+
+# (D) Add or remove space between 'invariant' and '('.
+sp_invariant_paren              = ignore   # ignore/add/remove/force
+
+# (D) Add or remove space after the ')' in 'invariant (C) c'.
+sp_after_invariant_paren        = ignore   # ignore/add/remove/force
+
+# Add or remove space before empty statement ';' on 'if', 'for' and 'while'.
+sp_special_semi                 = ignore   # ignore/add/remove/force
+
+# Add or remove space before ';'.
+#
+# Default: remove
+sp_before_semi                  = remove   # ignore/add/remove/force
+
+# Add or remove space before ';' in non-empty 'for' statements.
+sp_before_semi_for              = remove   # ignore/add/remove/force
+
+# Add or remove space before a semicolon of an empty part of a for statement.
+sp_before_semi_for_empty        = force    # ignore/add/remove/force
+
+# Add or remove space between the semicolons of an empty middle part of a for
+# statement, as in 'for ( ; <here> ; )'.
+sp_between_semi_for_empty       = ignore   # ignore/add/remove/force/not_defined
+
+# Add or remove space after ';', except when followed by a comment.
+#
+# Default: add
+sp_after_semi                   = force    # ignore/add/remove/force
+
+# Add or remove space after ';' in non-empty 'for' statements.
+#
+# Default: force
+sp_after_semi_for               = force    # ignore/add/remove/force
+
+# Add or remove space after the final semicolon of an empty part of a for
+# statement, as in 'for ( ; ; <here> )'.
+sp_after_semi_for_empty         = force    # ignore/add/remove/force
+
+# Add or remove space before '[' (except '[]').
+sp_before_square                = ignore   # ignore/add/remove/force
+
+# Add or remove space before '[' for a variable definition.
+#
+# Default: remove
+sp_before_vardef_square         = ignore   # ignore/add/remove/force
+
+# Add or remove space before '[' for asm block.
+sp_before_square_asm_block      = ignore   # ignore/add/remove/force
+
+# Add or remove space before '[]'.
+sp_before_squares               = ignore   # ignore/add/remove/force
+
+# Add or remove space before C++17 structured bindings.
+sp_cpp_before_struct_binding    = ignore   # ignore/add/remove/force
+
+# Add or remove space inside a non-empty '[' and ']'.
+sp_inside_square                = ignore   # ignore/add/remove/force
+
+# Add or remove space inside '[]'.
+sp_inside_square_empty          = remove   # ignore/add/remove/force/not_defined
+
+# (OC) Add or remove space inside a non-empty Objective-C boxed array '@[' and
+# ']'. If set to ignore, sp_inside_square is used.
+sp_inside_square_oc_array       = ignore   # ignore/add/remove/force
+
+# Add or remove space after ',', i.e. 'a,b' vs. 'a, b'.
+sp_after_comma                  = add      # ignore/add/remove/force
+
+# Add or remove space before ','.
+#
+# Default: remove
+sp_before_comma                 = remove   # ignore/add/remove/force
+
+# (C#) Add or remove space between ',' and ']' in multidimensional array type
+# like 'int[,,]'.
+sp_after_mdatype_commas         = ignore   # ignore/add/remove/force
+
+# (C#) Add or remove space between '[' and ',' in multidimensional array type
+# like 'int[,,]'.
+sp_before_mdatype_commas        = ignore   # ignore/add/remove/force
+
+# (C#) Add or remove space between ',' in multidimensional array type
+# like 'int[,,]'.
+sp_between_mdatype_commas       = ignore   # ignore/add/remove/force
+
+# Add or remove space between an open parenthesis and comma,
+# i.e. '(,' vs. '( ,'.
+#
+# Default: force
+sp_paren_comma                  = force    # ignore/add/remove/force
+
+# Add or remove space after the variadic '...' when preceded by a
+# non-punctuator.
+# The value REMOVE will be overriden with FORCE
+sp_after_ellipsis               = ignore   # ignore/add/remove/force/not_defined
+
+# Add or remove space before the variadic '...' when preceded by a
+# non-punctuator.
+sp_before_ellipsis              = force    # ignore/add/remove/force
+
+# Add or remove space between a type and '...'.
+sp_type_ellipsis                = force    # ignore/add/remove/force
+
+# Add or remove space between a '*' and '...'.
+sp_ptr_type_ellipsis            = ignore   # ignore/add/remove/force/not_defined
+
+# (D) Add or remove space between a type and '?'.
+sp_type_question                = ignore   # ignore/add/remove/force
+
+# Add or remove space between ')' and '...'.
+sp_paren_ellipsis               = force    # ignore/add/remove/force
+
+# Add or remove space between '&&' and '...'.
+sp_byref_ellipsis               = ignore   # ignore/add/remove/force/not_defined
+
+# Add or remove space between ')' and a qualifier such as 'const'.
+sp_paren_qualifier              = force    # ignore/add/remove/force
+
+# Add or remove space between ')' and 'noexcept'.
+sp_paren_noexcept               = ignore   # ignore/add/remove/force
+
+# Add or remove space after class ':'.
+sp_after_class_colon            = ignore   # ignore/add/remove/force
+
+# Add or remove space before class ':'.
+sp_before_class_colon           = ignore   # ignore/add/remove/force
+
+# Add or remove space after class constructor ':'.
+sp_after_constr_colon           = ignore   # ignore/add/remove/force
+
+# Add or remove space before class constructor ':'.
+sp_before_constr_colon          = ignore   # ignore/add/remove/force
+
+# Add or remove space before case ':'.
+#
+# Default: remove
+sp_before_case_colon            = remove   # ignore/add/remove/force
+
+# Add or remove space between 'operator' and operator sign.
+sp_after_operator               = ignore   # ignore/add/remove/force
+
+# Add or remove space between the operator symbol and the open parenthesis, as
+# in 'operator ++('.
+sp_after_operator_sym           = ignore   # ignore/add/remove/force
+
+# Overrides sp_after_operator_sym when the operator has no arguments, as in
+# 'operator *()'.
+sp_after_operator_sym_empty     = ignore   # ignore/add/remove/force
+
+# Add or remove space after C/D cast, i.e. 'cast(int)a' vs. 'cast(int) a' or
+# '(int)a' vs. '(int) a'.
+sp_after_cast                   = ignore   # ignore/add/remove/force
+
+# Add or remove spaces inside cast parentheses.
+sp_inside_paren_cast            = remove   # ignore/add/remove/force
+
+# Add or remove space between the type and open parenthesis in a C++ cast,
+# i.e. 'int(exp)' vs. 'int (exp)'.
+sp_cpp_cast_paren               = ignore   # ignore/add/remove/force
+
+# Add or remove space between 'sizeof' and '('.
+sp_sizeof_paren                 = ignore   # ignore/add/remove/force
+
+# Add or remove space between 'sizeof' and '...'.
+sp_sizeof_ellipsis              = remove   # ignore/add/remove/force
+
+# Add or remove space between 'sizeof...' and '('.
+sp_sizeof_ellipsis_paren        = remove   # ignore/add/remove/force
+
+# Add or remove space between '...' and a parameter pack.
+sp_ellipsis_parameter_pack      = ignore   # ignore/add/remove/force/not_defined
+
+# Add or remove space between a parameter pack and '...'.
+sp_parameter_pack_ellipsis      = ignore   # ignore/add/remove/force/not_defined
+
+# Add or remove space between 'decltype' and '('.
+sp_decltype_paren               = ignore   # ignore/add/remove/force
+
+# (Pawn) Add or remove space after the tag keyword.
+#sp_after_tag                    = ignore   # ignore/add/remove/force
+
+# Add or remove space inside enum '{' and '}'.
+sp_inside_braces_enum           = force    # ignore/add/remove/force
+
+# Add or remove space inside struct/union '{' and '}'.
+sp_inside_braces_struct         = force    # ignore/add/remove/force
+
+# (OC) Add or remove space inside Objective-C boxed dictionary '{' and '}'
+#sp_inside_braces_oc_dict        = ignore   # ignore/add/remove/force
+
+# Add or remove space after open brace in an unnamed temporary
+# direct-list-initialization.
+sp_after_type_brace_init_lst_open = ignore   # ignore/add/remove/force
+
+# Add or remove space before close brace in an unnamed temporary
+# direct-list-initialization.
+sp_before_type_brace_init_lst_close = ignore   # ignore/add/remove/force
+
+# Add or remove space inside an unnamed temporary direct-list-initialization.
+sp_inside_type_brace_init_lst   = ignore   # ignore/add/remove/force
+
+# Add or remove space inside '{' and '}'.
+sp_inside_braces                = remove   # ignore/add/remove/force
+
+# Add or remove space inside '{}'.
+sp_inside_braces_empty          = remove   # ignore/add/remove/force
+
+# Add or remove space around trailing return operator '->'.
+sp_trailing_return              = ignore   # ignore/add/remove/force
+
+# Add or remove space between return type and function name. A minimum of 1
+# is forced except for pointer return types.
+sp_type_func                    = remove   # ignore/add/remove/force
+
+# Add or remove space between type and open brace of an unnamed temporary
+# direct-list-initialization.
+sp_type_brace_init_lst          = ignore   # ignore/add/remove/force
+
+# Add or remove space between function name and '(' on function declaration.
+sp_func_proto_paren             = remove   # ignore/add/remove/force
+
+# Add or remove space between function name and '()' on function declaration
+# without parameters.
+sp_func_proto_paren_empty       = remove   # ignore/add/remove/force
+
+# Add or remove space between function name and '(' with a typedef specifier.
+sp_func_type_paren              = remove   # ignore/add/remove/force
+
+# Add or remove space between alias name and '(' of a non-pointer function type typedef.
+sp_func_def_paren               = ignore   # ignore/add/remove/force
+
+# Add or remove space between function name and '()' on function definition
+# without parameters.
+sp_func_def_paren_empty         = remove   # ignore/add/remove/force
+
+# Add or remove space inside empty function '()'.
+# Overrides sp_after_angle unless use_sp_after_angle_always is set to true.
+sp_inside_fparens               = remove   # ignore/add/remove/force
+
+# Add or remove space inside function '(' and ')'.
+sp_inside_fparen                = remove   # ignore/add/remove/force
+
+# Add or remove space inside the first parentheses in a function type, as in
+# 'void (*x)(...)'.
+sp_inside_tparen                = remove   # ignore/add/remove/force
+
+# Add or remove space between the ')' and '(' in a function type, as in
+# 'void (*x)(...)'.
+sp_after_tparen_close           = remove   # ignore/add/remove/force
+
+# Add or remove space between ']' and '(' when part of a function call.
+sp_square_fparen                = ignore   # ignore/add/remove/force
+
+# Add or remove space between ')' and '{' of function.
+sp_fparen_brace                 = ignore    # ignore/add/remove/force
+
+# Add or remove space between ')' and '{' of s function call in object
+# initialization.
+#
+# Overrides sp_fparen_brace.
+sp_fparen_brace_initializer     = ignore   # ignore/add/remove/force
+
+# (Java) Add or remove space between ')' and '{{' of double brace initializer.
+sp_fparen_dbrace                = ignore   # ignore/add/remove/force
+
+# Add or remove space between function name and '(' on function calls.
+sp_func_call_paren              = ignore   # ignore/add/remove/force
+
+# Add or remove space between function name and '()' on function calls without
+# parameters. If set to ignore (the default), sp_func_call_paren is used.
+sp_func_call_paren_empty        = ignore   # ignore/add/remove/force
+
+# Add or remove space between the user function name and '(' on function
+# calls. You need to set a keyword to be a user function in the config file,
+# like:
+#   set func_call_user tr _ i18n
+sp_func_call_user_paren         = ignore   # ignore/add/remove/force
+
+# Add or remove space inside user function '(' and ')'.
+sp_func_call_user_inside_fparen = ignore   # ignore/add/remove/force
+
+# Add or remove space between nested parentheses with user functions,
+# i.e. '((' vs. '( ('.
+sp_func_call_user_paren_paren   = ignore   # ignore/add/remove/force
+
+# Add or remove space between a constructor/destructor and the open
+# parenthesis.
+sp_func_class_paren             = ignore   # ignore/add/remove/force
+
+# Add or remove space between a constructor without parameters or destructor
+# and '()'.
+sp_func_class_paren_empty       = ignore   # ignore/add/remove/force
+
+# Add or remove space after 'return'.
+#
+# Default: force
+sp_return                       = force    # ignore/add/remove/force/not_defined
+
+# Add or remove space between 'return' and '('.
+sp_return_paren                 = force    # ignore/add/remove/force
+
+# Add or remove space between 'return' and '{'.
+sp_return_brace                 = force    # ignore/add/remove/force
+
+# Add or remove space between '__attribute__' and '('.
+sp_attribute_paren              = remove   # ignore/add/remove/force
+
+# Add or remove space between 'defined' and '(' in '#if defined (FOO)'.
+sp_defined_paren                = force    # ignore/add/remove/force
+
+# Add or remove space between 'throw' and '(' in 'throw (something)'.
+sp_throw_paren                  = ignore   # ignore/add/remove/force
+
+# Add or remove space between 'throw' and anything other than '(' as in
+# '@throw [...];'.
+sp_after_throw                  = ignore   # ignore/add/remove/force
+
+# Add or remove space between 'catch' and '(' in 'catch (something) { }'.
+# If set to ignore, sp_before_sparen is used.
+sp_catch_paren                  = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove space between '@catch' and '('
+# in '@catch (something) { }'. If set to ignore, sp_catch_paren is used.
+sp_oc_catch_paren               = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove space before Objective-C protocol list
+# as in '@protocol Protocol<here><Protocol_A>' or '@interface MyClass : NSObject<here><MyProtocol>'.
+sp_before_oc_proto_list         = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove space between class name and '('
+# in '@interface className(categoryName)<ProtocolName>:BaseClass'
+sp_oc_classname_paren           = ignore   # ignore/add/remove/force
+
+# (D) Add or remove space between 'version' and '('
+# in 'version (something) { }'. If set to ignore, sp_before_sparen is used.
+sp_version_paren                = ignore   # ignore/add/remove/force
+
+# (D) Add or remove space between 'scope' and '('
+# in 'scope (something) { }'. If set to ignore, sp_before_sparen is used.
+sp_scope_paren                  = ignore   # ignore/add/remove/force
+
+# Add or remove space between 'super' and '(' in 'super (something)'.
+#
+# Default: remove
+sp_super_paren                  = ignore   # ignore/add/remove/force
+
+# Add or remove space between 'this' and '(' in 'this (something)'.
+#
+# Default: remove
+sp_this_paren                   = ignore   # ignore/add/remove/force
+
+# Add or remove space between a macro name and its definition.
+sp_macro                        = force    # ignore/add/remove/force
+
+# Add or remove space between a macro function ')' and its definition.
+sp_macro_func                   = force    # ignore/add/remove/force
+
+# Add or remove space between 'else' and '{' if on the same line.
+sp_else_brace                   = force    # ignore/add/remove/force
+
+# Add or remove space between '}' and 'else' if on the same line.
+sp_brace_else                   = force    # ignore/add/remove/force
+
+# Add or remove space between '}' and the name of a typedef on the same line.
+sp_brace_typedef                = force    # ignore/add/remove/force
+
+# Add or remove space before the '{' of a 'catch' statement, if the '{' and
+# 'catch' are on the same line, as in 'catch (decl) <here> {'.
+sp_catch_brace                  = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove space before the '{' of a '@catch' statement, if the '{'
+# and '@catch' are on the same line, as in '@catch (decl) <here> {'.
+# If set to ignore, sp_catch_brace is used.
+sp_oc_catch_brace               = ignore   # ignore/add/remove/force
+
+# Add or remove space between '}' and 'catch' if on the same line.
+sp_brace_catch                  = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove space between '}' and '@catch' if on the same line.
+# If set to ignore, sp_brace_catch is used.
+sp_oc_brace_catch               = ignore   # ignore/add/remove/force
+
+# Add or remove space between 'finally' and '{' if on the same line.
+sp_finally_brace                = ignore   # ignore/add/remove/force
+
+# Add or remove space between '}' and 'finally' if on the same line.
+sp_brace_finally                = ignore   # ignore/add/remove/force
+
+# Add or remove space between 'try' and '{' if on the same line.
+sp_try_brace                    = ignore   # ignore/add/remove/force
+
+# Add or remove space between get/set and '{' if on the same line.
+sp_getset_brace                 = ignore   # ignore/add/remove/force
+
+# Add or remove space between a variable and '{' for C++ uniform
+# initialization.
+sp_word_brace_init_lst          = ignore   # ignore/add/remove/force
+
+# Add or remove space between a variable and '{' for a namespace.
+#
+# Default: add
+sp_word_brace_ns                = ignore   # ignore/add/remove/force
+
+# Add or remove space before the '::' operator.
+sp_before_dc                    = ignore   # ignore/add/remove/force
+
+# Add or remove space after the '::' operator.
+sp_after_dc                     = ignore   # ignore/add/remove/force
+
+# (D) Add or remove around the D named array initializer ':' operator.
+sp_d_array_colon                = remove   # ignore/add/remove/force
+
+# Add or remove space after the '!' (not) unary operator.
+#
+# Default: remove
+sp_not                          = remove   # ignore/add/remove/force
+
+# Add or remove space after the '~' (invert) unary operator.
+#
+# Default: remove
+sp_inv                          = remove   # ignore/add/remove/force
+
+# Add or remove space after the '&' (address-of) unary operator. This does not
+# affect the spacing after a '&' that is part of a type.
+#
+# Default: remove
+sp_addr                         = remove   # ignore/add/remove/force
+
+# Add or remove space around the '.' or '->' operators.
+#
+# Default: remove
+sp_member                       = remove   # ignore/add/remove/force
+
+# Add or remove space after the '*' (dereference) unary operator. This does
+# not affect the spacing after a '*' that is part of a type.
+#
+# Default: remove
+sp_deref                        = remove   # ignore/add/remove/force
+
+# Add or remove space after '+' or '-', as in 'x = -5' or 'y = +7'.
+#
+# Default: remove
+sp_sign                         = remove   # ignore/add/remove/force
+
+# Add or remove space between '++' and '--' the word to which it is being
+# applied, as in '(--x)' or 'y++;'.
+#
+# Default: remove
+sp_incdec                       = remove   # ignore/add/remove/force
+
+# Add or remove space before a backslash-newline at the end of a line.
+#
+# Default: add
+sp_before_nl_cont               = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove space after the scope '+' or '-', as in '-(void) foo;'
+# or '+(int) bar;'.
+sp_after_oc_scope               = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove space after the colon in message specs,
+# i.e. '-(int) f:(int) x;' vs. '-(int) f: (int) x;'.
+sp_after_oc_colon               = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove space before the colon in message specs,
+# i.e. '-(int) f: (int) x;' vs. '-(int) f : (int) x;'.
+sp_before_oc_colon              = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove space after the colon in immutable dictionary expression
+# 'NSDictionary *test = @{@"foo" :@"bar"};'.
+sp_after_oc_dict_colon          = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove space before the colon in immutable dictionary expression
+# 'NSDictionary *test = @{@"foo" :@"bar"};'.
+sp_before_oc_dict_colon         = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove space after the colon in message specs,
+# i.e. '[object setValue:1];' vs. '[object setValue: 1];'.
+sp_after_send_oc_colon          = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove space before the colon in message specs,
+# i.e. '[object setValue:1];' vs. '[object setValue :1];'.
+sp_before_send_oc_colon         = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove space after the (type) in message specs,
+# i.e. '-(int)f: (int) x;' vs. '-(int)f: (int)x;'.
+sp_after_oc_type                = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove space after the first (type) in message specs,
+# i.e. '-(int) f:(int)x;' vs. '-(int)f:(int)x;'.
+sp_after_oc_return_type         = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove space between '@selector' and '(',
+# i.e. '@selector(msgName)' vs. '@selector (msgName)'.
+# Also applies to '@protocol()' constructs.
+sp_after_oc_at_sel              = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove space between '@selector(x)' and the following word,
+# i.e. '@selector(foo) a:' vs. '@selector(foo)a:'.
+sp_after_oc_at_sel_parens       = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove space inside '@selector' parentheses,
+# i.e. '@selector(foo)' vs. '@selector( foo )'.
+# Also applies to '@protocol()' constructs.
+sp_inside_oc_at_sel_parens      = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove space before a block pointer caret,
+# i.e. '^int (int arg){...}' vs. ' ^int (int arg){...}'.
+sp_before_oc_block_caret        = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove space after a block pointer caret,
+# i.e. '^int (int arg){...}' vs. '^ int (int arg){...}'.
+sp_after_oc_block_caret         = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove space between the receiver and selector in a message,
+# as in '[receiver selector ...]'.
+sp_after_oc_msg_receiver        = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove space after '@property'.
+sp_after_oc_property            = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove space between '@synchronized' and the open parenthesis,
+# i.e. '@synchronized(foo)' vs. '@synchronized (foo)'.
+sp_after_oc_synchronized        = ignore   # ignore/add/remove/force
+
+# Add or remove space around the ':' in 'b ? t : f'.
+sp_cond_colon                   = force    # ignore/add/remove/force
+
+# Add or remove space before the ':' in 'b ? t : f'.
+#
+# Overrides sp_cond_colon.
+sp_cond_colon_before            = ignore   # ignore/add/remove/force
+
+# Add or remove space after the ':' in 'b ? t : f'.
+#
+# Overrides sp_cond_colon.
+sp_cond_colon_after             = ignore   # ignore/add/remove/force
+
+# Add or remove space around the '?' in 'b ? t : f'.
+sp_cond_question                = force    # ignore/add/remove/force
+
+# Add or remove space before the '?' in 'b ? t : f'.
+#
+# Overrides sp_cond_question.
+sp_cond_question_before         = ignore    # ignore/add/remove/force
+
+# Add or remove space after the '?' in 'b ? t : f'.
+#
+# Overrides sp_cond_question.
+sp_cond_question_after          = ignore    # ignore/add/remove/force
+
+# In the abbreviated ternary form '(a ?: b)', add or remove space between '?'
+# and ':'.
+#
+# Overrides all other sp_cond_* options.
+sp_cond_ternary_short           = remove    # ignore/add/remove/force
+
+# Fix the spacing between 'case' and the label. Only 'ignore' and 'force' make
+# sense here.
+sp_case_label                   = force    # ignore/add/remove/force
+
+# (D) Add or remove space around the D '..' operator.
+sp_range                        = ignore   # ignore/add/remove/force
+
+# Add or remove space after ':' in a Java/C++11 range-based 'for',
+# as in 'for (Type var : expr)'.
+sp_after_for_colon              = ignore   # ignore/add/remove/force
+
+# Add or remove space before ':' in a Java/C++11 range-based 'for',
+# as in 'for (Type var : expr)'.
+sp_before_for_colon             = ignore   # ignore/add/remove/force
+
+# (D) Add or remove space between 'extern' and '(' as in 'extern (C)'.
+sp_extern_paren                 = ignore   # ignore/add/remove/force
+
+# Add or remove space after the opening of a C++ comment,
+# i.e. '// A' vs. '//A'.
+sp_cmt_cpp_start                = force    # ignore/add/remove/force
+
+# Add or remove space in a C++ region marker comment, as in '// <here> BEGIN'.
+# A region marker is defined as a comment which is not preceded by other text
+# (i.e. the comment is the first non-whitespace on the line), and which starts
+# with either 'BEGIN' or 'END'.
+#
+# Overrides sp_cmt_cpp_start.
+sp_cmt_cpp_region               = ignore   # ignore/add/remove/force/not_defined
+
+# If true, space is added with sp_cmt_cpp_start will be added after doxygen
+# sequences like '///', '///<', '//!' and '//!<'.
+sp_cmt_cpp_doxygen              = true     # true/false
+
+# If true, space is added with sp_cmt_cpp_start will be added after Qt
+# translator or meta-data comments like '//:', '//=', and '//~'.
+sp_cmt_cpp_qttr                 = true     # true/false
+
+# Add or remove space between #else or #endif and a trailing comment.
+sp_endif_cmt                    = force    # ignore/add/remove/force
+
+# Add or remove space after 'new', 'delete' and 'delete[]'.
+sp_after_new                    = ignore   # ignore/add/remove/force
+
+# Add or remove space between 'new' and '(' in 'new()'.
+sp_between_new_paren            = ignore   # ignore/add/remove/force
+
+# Add or remove space between ')' and type in 'new(foo) BAR'.
+sp_after_newop_paren            = ignore   # ignore/add/remove/force
+
+# Add or remove space inside parenthesis of the new operator
+# as in 'new(foo) BAR'.
+sp_inside_newop_paren           = ignore   # ignore/add/remove/force
+
+# Add or remove space after the open parenthesis of the new operator,
+# as in 'new(foo) BAR'.
+#
+# Overrides sp_inside_newop_paren.
+sp_inside_newop_paren_open      = ignore   # ignore/add/remove/force
+
+# Add or remove space before the close parenthesis of the new operator,
+# as in 'new(foo) BAR'.
+#
+# Overrides sp_inside_newop_paren.
+sp_inside_newop_paren_close     = ignore   # ignore/add/remove/force
+
+# Add or remove space before a trailing comment.
+sp_before_tr_cmt                = ignore   # ignore/add/remove/force/not_defined
+
+# Number of spaces before a trailing comment.
+sp_num_before_tr_cmt            = 0        # unsigned number
+
+# Add or remove space before an embedded comment.
+#
+# Default: force
+sp_before_emb_cmt               = force    # ignore/add/remove/force/not_defined
+
+# Number of spaces before an embedded comment.
+#
+# Default: 1
+sp_num_before_emb_cmt           = 1        # unsigned number
+
+# Add or remove space after an embedded comment.
+#
+# Default: force
+sp_after_emb_cmt                = force    # ignore/add/remove/force/not_defined
+
+# Number of spaces after an embedded comment.
+#
+# Default: 1
+sp_num_after_emb_cmt            = 1        # unsigned number
+
+# (Java) Add or remove space between an annotation and the open parenthesis.
+sp_annotation_paren             = ignore   # ignore/add/remove/force
+
+# If true, vbrace tokens are dropped to the previous token and skipped.
+sp_skip_vbrace_tokens           = false    # true/false
+
+# Add or remove space after 'noexcept'.
+sp_after_noexcept               = ignore   # ignore/add/remove/force
+
+# Add or remove space after '_'.
+sp_vala_after_translation       = ignore   # ignore/add/remove/force
+
+# If true, a <TAB> is inserted after #define.
+force_tab_after_define          = false    # true/false
+
+#
+# Indenting options
+#
+
+# The number of columns to indent per level. Usually 2, 3, 4, or 8.
+#
+# Default: 8
+indent_columns                  = 4        # unsigned number
+
+# The continuation indent. If non-zero, this overrides the indent of '(', '['
+# and '=' continuation indents. Negative values are OK; negative value is
+# absolute and not increased for each '(' or '[' level.
+#
+# For FreeBSD, this is set to 4.
+indent_continue                 = 8        # number
+
+# The continuation indent, only for class header line(s). If non-zero, this
+# overrides the indent of 'class' continuation indents.
+indent_continue_class_head      = 0        # unsigned number
+
+# Whether to indent empty lines (i.e. lines which contain only spaces before
+# the newline character).
+indent_single_newlines          = false    # true/false
+
+# The continuation indent for func_*_param if they are true. If non-zero, this
+# overrides the indent.
+indent_param                    = 4        # unsigned number
+
+# How to use tabs when indenting code.
+#
+# 0: Spaces only
+# 1: Indent with tabs to brace level, align with spaces (default)
+# 2: Indent and align with tabs, using spaces when not on a tabstop
+#
+# Default: 1
+indent_with_tabs                = 0        # unsigned number
+
+# Whether to indent comments that are not at a brace level with tabs on a
+# tabstop. Requires indent_with_tabs=2. If false, will use spaces.
+indent_cmt_with_tabs            = false    # true/false
+
+# Whether to indent strings broken by '\' so that they line up.
+indent_align_string             = false    # true/false
+
+# The number of spaces to indent multi-line XML strings.
+# Requires indent_align_string=true.
+indent_xml_string               = 4        # unsigned number
+
+# Spaces to indent '{' from level.
+indent_brace                    = 0        # unsigned number
+
+# Whether braces are indented to the body level.
+indent_braces                   = false    # true/false
+
+# Whether to disable indenting function braces if indent_braces=true.
+indent_braces_no_func           = false    # true/false
+
+# Whether to disable indenting class braces if indent_braces=true.
+indent_braces_no_class          = false    # true/false
+
+# Whether to disable indenting struct braces if indent_braces=true.
+indent_braces_no_struct         = false    # true/false
+
+# Whether to indent based on the size of the brace parent,
+# i.e. 'if' => 3 spaces, 'for' => 4 spaces, etc.
+indent_brace_parent             = false    # true/false
+
+# Whether to indent based on the open parenthesis instead of the open brace
+# in '({\n'.
+indent_paren_open_brace         = false    # true/false
+
+# (C#) Whether to indent the brace of a C# delegate by another level.
+indent_cs_delegate_brace        = false    # true/false
+
+# (C#) Whether to indent a C# delegate (to handle delegates with no brace) by
+# another level.
+indent_cs_delegate_body         = false    # true/false
+
+# Whether to indent the body of a 'namespace'.
+indent_namespace                = false    # true/false
+
+# Whether to indent only the first namespace, and not any nested namespaces.
+# Requires indent_namespace=true.
+indent_namespace_single_indent  = false    # true/false
+
+# The number of spaces to indent a namespace block.
+# If set to zero, use the value indent_columns
+indent_namespace_level          = 0        # unsigned number
+
+# If the body of the namespace is longer than this number, it won't be
+# indented. Requires indent_namespace=true. 0 means no limit.
+indent_namespace_limit          = 0        # unsigned number
+
+# Whether the 'extern "C"' body is indented.
+indent_extern                   = false    # true/false
+
+# Whether the 'class' body is indented.
+indent_class                    = false    # true/false
+
+# Additional indent before the leading base class colon.
+# Negative values decrease indent down to the first column.
+# Requires a newline break before colon (see pos_class_colon
+# and nl_class_colon)
+indent_before_class_colon       = 0        # number
+
+# Whether to indent the stuff after a leading base class colon.
+indent_class_colon              = false    # true/false
+
+# Whether to indent based on a class colon instead of the stuff after the
+# colon. Requires indent_class_colon=true.
+indent_class_on_colon           = false    # true/false
+
+# Whether to indent the stuff after a leading class initializer colon.
+indent_constr_colon             = false    # true/false
+
+# Virtual indent from the ':' for member initializers.
+#
+# Default: 2
+indent_ctor_init_leading        = 0        # unsigned number
+
+# Virtual indent from the ':' for following member initializers.
+#
+# Default: 2
+indent_ctor_init_following      = 2        # unsigned number
+
+# Additional indent for constructor initializer list.
+# Negative values decrease indent down to the first column.
+indent_ctor_init                = 0        # number
+
+# Whether to indent 'if' following 'else' as a new block under the 'else'.
+# If false, 'else\nif' is treated as 'else if' for indenting purposes.
+indent_else_if                  = false    # true/false
+
+# Amount to indent variable declarations after a open brace.
+#
+#  <0: Relative
+# >=0: Absolute
+indent_var_def_blk              = 0        # number
+
+# Whether to indent continued variable declarations instead of aligning.
+indent_var_def_cont             = true     # true/false
+
+# Whether to indent continued shift expressions ('<<' and '>>') instead of
+# aligning. Set align_left_shift=false when enabling this.
+indent_shift                    = true     # true/false
+
+# Whether to force indentation of function definitions to start in column 1.
+indent_func_def_force_col1      = false    # true/false
+
+# Whether to indent continued function call parameters one indent level,
+# rather than aligning parameters under the open parenthesis.
+indent_func_call_param          = true     # true/false
+
+# Whether to indent continued function definition parameters one indent level,
+# rather than aligning parameters under the open parenthesis.
+indent_func_def_param           = true     # true/false
+
+# for function definitions, only if indent_func_def_param is false
+# Allows to align params when appropriate and indent them when not
+# behave as if it was true if paren position is more than this value
+# if paren position is more than the option value
+indent_func_def_param_paren_pos_threshold = 0        # unsigned number
+
+# Whether to indent continued function call prototype one indent level,
+# rather than aligning parameters under the open parenthesis.
+indent_func_proto_param         = true     # true/false
+
+# Whether to indent continued function call declaration one indent level,
+# rather than aligning parameters under the open parenthesis.
+indent_func_class_param         = true     # true/false
+
+# Whether to indent continued class variable constructors one indent level,
+# rather than aligning parameters under the open parenthesis.
+indent_func_ctor_var_param      = true     # true/false
+
+# Whether to indent continued template parameter list one indent level,
+# rather than aligning parameters under the open parenthesis.
+indent_template_param           = true     # true/false
+
+# Double the indent for indent_func_xxx_param options.
+# Use both values of the options indent_columns and indent_param.
+indent_func_param_double        = true     # true/false
+
+# Indentation column for standalone 'const' qualifier on a function
+# prototype.
+indent_func_const               = 0        # unsigned number
+
+# Indentation column for standalone 'throw' qualifier on a function
+# prototype.
+indent_func_throw               = 0        # unsigned number
+
+# How to indent within a macro followed by a brace on the same line
+# This allows reducing the indent in macros that have (for example)
+# `do { ... } while (0)` blocks bracketing them.
+#
+# true:  add an indent for the brace on the same line as the macro
+# false: do not add an indent for the brace on the same line as the macro
+#
+# Default: true
+indent_macro_brace              = false    # true/false
+
+# The number of spaces to indent a continued '->' or '.'.
+# Usually set to 0, 1, or indent_columns.
+indent_member                   = 0        # unsigned number
+
+# Whether lines broken at '.' or '->' should be indented by a single indent.
+# The indent_member option will not be effective if this is set to true.
+indent_member_single            = true     # true/false
+
+# Spaces to indent single line ('//') comments on lines before code.
+indent_single_line_comments_before = 0        # unsigned number
+
+# Spaces to indent single line ('//') comments on lines after code.
+indent_single_line_comments_after = 0        # unsigned number
+
+# When opening a paren for a control statement (if, for, while, etc), increase
+# the indent level by this value. Negative values decrease the indent level.
+indent_sparen_extra             = 0        # number
+
+# Whether to indent trailing single line ('//') comments relative to the code
+# instead of trying to keep the same absolute column.
+indent_relative_single_line_comments = false    # true/false
+
+# Spaces to indent 'case' from 'switch'. Usually 0 or indent_columns.
+indent_switch_case              = 0        # unsigned number
+
+# Spaces to indent the body of a 'switch' before any 'case'.
+# Usually the same as indent_columns or indent_switch_case.
+indent_switch_body              = 0        # unsigned number
+
+# indent 'break' with 'case' from 'switch'.
+indent_switch_break_with_case   = false    # true/false
+
+# Whether to indent preprocessor statements inside of switch statements.
+#
+# Default: true
+indent_switch_pp                = false    # true/false
+
+# Spaces to shift the 'case' line, without affecting any other lines.
+# Usually 0.
+indent_case_shift               = 0        # unsigned number
+
+# Spaces to indent '{' from 'case'. By default, the brace will appear under
+# the 'c' in case. Usually set to 0 or indent_columns. Negative values are OK.
+indent_case_brace               = 0        # number
+
+# Whether to indent comments not found in first column.
+#
+# Default: true
+indent_comment                  = true     # true/false
+
+# Whether to indent comments found in first column.
+indent_col1_comment             = false    # true/false
+
+# Whether to indent multi string literal in first column.
+indent_col1_multi_string_literal = false    # true/false
+
+# Align comments on adjacent lines that are this many columns apart or less.
+#
+# Default: 3
+indent_comment_align_thresh     = 3        # unsigned number
+
+# Whether to ignore indent for goto labels.
+indent_ignore_label             = true    # true/false
+
+# How to indent goto labels.
+#
+#  >0: Absolute column where 1 is the leftmost column
+# <=0: Subtract from brace indent
+#
+# Default: 1
+indent_label                    = 1        # number
+
+# How to indent access specifiers that are followed by a
+# colon.
+#
+#  >0: Absolute column where 1 is the leftmost column
+# <=0: Subtract from brace indent
+#
+# Default: 1
+indent_access_spec              = 1        # number
+
+# Whether to indent the code after an access specifier by one level.
+# If true, this option forces 'indent_access_spec=0'.
+indent_access_spec_body         = false    # true/false
+
+# If an open parenthesis is followed by a newline, whether to indent the next
+# line so that it lines up after the open parenthesis (not recommended).
+indent_paren_nl                 = false    # true/false
+
+# How to indent a close parenthesis after a newline.
+#
+# 0: Indent to body level (default)
+# 1: Align under the open parenthesis
+# 2: Indent to the brace level
+indent_paren_close              = 1        # unsigned number
+
+# Whether to indent the open parenthesis of a function definition,
+# if the parenthesis is on its own line.
+indent_paren_after_func_def     = false    # true/false
+
+# Whether to indent the open parenthesis of a function declaration,
+# if the parenthesis is on its own line.
+indent_paren_after_func_decl    = false    # true/false
+
+# Whether to indent the open parenthesis of a function call,
+# if the parenthesis is on its own line.
+indent_paren_after_func_call    = false    # true/false
+
+# Whether to indent a comma when inside a brace.
+# If true, aligns under the open brace.
+indent_comma_brace              = false    # true/false
+
+# Whether to indent a comma when inside a parenthesis.
+# If true, aligns under the open parenthesis.
+indent_comma_paren              = false    # true/false
+
+# Whether to indent a Boolean operator when inside a parenthesis.
+# If true, aligns under the open parenthesis.
+indent_bool_paren               = false    # true/false
+
+# Whether to indent a semicolon when inside a for parenthesis.
+# If true, aligns under the open for parenthesis.
+indent_semicolon_for_paren      = false    # true/false
+
+# Whether to align the first expression to following ones
+# if indent_bool_paren=true.
+indent_first_bool_expr          = false    # true/false
+
+# Whether to align the first expression to following ones
+# if indent_semicolon_for_paren=true.
+indent_first_for_expr           = false    # true/false
+
+# If an open square is followed by a newline, whether to indent the next line
+# so that it lines up after the open square (not recommended).
+indent_square_nl                = false    # true/false
+
+# (ESQL/C) Whether to preserve the relative indent of 'EXEC SQL' bodies.
+indent_preserve_sql             = false    # true/false
+
+# Whether to align continued statements at the '='. If false or if the '=' is
+# followed by a newline, the next line is indent one tab.
+#
+# Default: true
+indent_align_assign             = false    # true/false
+
+# If true, the indentation of the chunks after a '=' sequence will be set at
+# LHS token indentation column before '='.
+indent_off_after_assign         = false    # true/false
+
+# Whether to align continued statements at the '('. If false or the '(' is
+# followed by a newline, the next line indent is one tab.
+#
+# Default: true
+indent_align_paren              = true     # true/false
+
+# (OC) Whether to indent Objective-C code inside message selectors.
+indent_oc_inside_msg_sel        = false    # true/false
+
+# (OC) Whether to indent Objective-C blocks at brace level instead of usual
+# rules.
+indent_oc_block                 = false    # true/false
+
+# (OC) Indent for Objective-C blocks in a message relative to the parameter
+# name.
+#
+# =0: Use indent_oc_block rules
+# >0: Use specified number of spaces to indent
+indent_oc_block_msg             = 0        # unsigned number
+
+# (OC) Minimum indent for subsequent parameters
+indent_oc_msg_colon             = 0        # unsigned number
+
+# (OC) Whether to prioritize aligning with initial colon (and stripping spaces
+# from lines, if necessary).
+#
+# Default: true
+indent_oc_msg_prioritize_first_colon = true     # true/false
+
+# (OC) Whether to indent blocks the way that Xcode does by default
+# (from the keyword if the parameter is on its own line; otherwise, from the
+# previous indentation level). Requires indent_oc_block_msg=true.
+indent_oc_block_msg_xcode_style = false    # true/false
+
+# (OC) Whether to indent blocks from where the brace is, relative to a
+# message keyword. Requires indent_oc_block_msg=true.
+indent_oc_block_msg_from_keyword = false    # true/false
+
+# (OC) Whether to indent blocks from where the brace is, relative to a message
+# colon. Requires indent_oc_block_msg=true.
+indent_oc_block_msg_from_colon  = false    # true/false
+
+# (OC) Whether to indent blocks from where the block caret is.
+# Requires indent_oc_block_msg=true.
+indent_oc_block_msg_from_caret  = false    # true/false
+
+# (OC) Whether to indent blocks from where the brace caret is.
+# Requires indent_oc_block_msg=true.
+indent_oc_block_msg_from_brace  = false    # true/false
+
+# When indenting after virtual brace open and newline add further spaces to
+# reach this minimum indent.
+indent_min_vbrace_open          = 4        # unsigned number
+
+# Whether to add further spaces after regular indent to reach next tabstop
+# when identing after virtual brace open and newline.
+indent_vbrace_open_on_tabstop   = false    # true/false
+
+# How to indent after a brace followed by another token (not a newline).
+# true:  indent all contained lines to match the token
+# false: indent all contained lines to match the brace
+#
+# Default: true
+indent_token_after_brace        = false    # true/false
+
+# Whether to indent the body of a C++11 lambda.
+indent_cpp_lambda_body          = false    # true/false
+
+# How to indent compound literals that are being returned.
+# true: add both the indent from return & the compound literal open brace (ie:
+#       2 indent levels)
+# false: only indent 1 level, don't add the indent for the open brace, only add
+#        the indent for the return.
+#
+# Default: true
+indent_compound_literal_return  = true     # true/false
+
+# (C#) Whether to indent a 'using' block if no braces are used.
+#
+# Default: true
+indent_using_block              = true     # true/false
+
+# How to indent the continuation of ternary operator.
+#
+# 0: Off (default)
+# 1: When the `if_false` is a continuation, indent it under `if_false`
+# 2: When the `:` is a continuation, indent it under `?`
+indent_ternary_operator         = 0        # unsigned number
+
+# Whether to indent the statments inside ternary operator.
+indent_inside_ternary_operator  = false    # true/false
+
+# If true, the indentation of the chunks after a `return` sequence will be set at return indentation column.
+indent_off_after_return         = false    # true/false
+
+# If true, the indentation of the chunks after a `return new` sequence will be set at return indentation column.
+indent_off_after_return_new     = false    # true/false
+
+# If true, the tokens after return are indented with regular single indentation. By default (false) the indentation is after the return token.
+indent_single_after_return      = false    # true/false
+
+# Whether to ignore indent and alignment for 'asm' blocks (i.e. assume they
+# have their own indentation).
+indent_ignore_asm_block         = true     # true/false
+
+# Don't indent the close parenthesis of a function definition,
+# if the parenthesis is on its own line.
+donot_indent_func_def_close_paren = false    # true/false
+
+#
+# Newline adding and removing options
+#
+
+# Whether to collapse empty blocks between '{' and '}'.
+nl_collapse_empty_body          = true     # true/false
+
+# Don't split one-line braced assignments, as in 'foo_t f = { 1, 2 };'.
+nl_assign_leave_one_liners      = true     # true/false
+
+# Don't split one-line braced statements inside a 'class xx { }' body.
+nl_class_leave_one_liners       = true     # true/false
+
+# Don't split one-line enums, as in 'enum foo { BAR = 15 };'
+nl_enum_leave_one_liners        = true     # true/false
+
+# Don't split one-line get or set functions.
+nl_getset_leave_one_liners      = true     # true/false
+
+# (C#) Don't split one-line property get or set functions.
+nl_cs_property_leave_one_liners = true     # true/false
+
+# Don't split one-line function definitions, as in 'int foo() { return 0; }'.
+# might modify nl_func_type_name
+nl_func_leave_one_liners        = true     # true/false
+
+# Don't split one-line C++11 lambdas, as in '[]() { return 0; }'.
+nl_cpp_lambda_leave_one_liners  = true     # true/false
+
+# Don't split one-line if/else statements, as in 'if(...) b++;'.
+nl_if_leave_one_liners          = false    # true/false
+
+# Don't split one-line while statements, as in 'while(...) b++;'.
+nl_while_leave_one_liners       = false    # true/false
+
+# Don't split one-line do statements, as in 'do { b++; } while(...);'.
+nl_do_leave_one_liners          = false    # true/false
+
+# Don't split one-line for statements, as in 'for(...) b++;'.
+nl_for_leave_one_liners         = false    # true/false
+
+# (OC) Don't split one-line Objective-C messages.
+nl_oc_msg_leave_one_liner       = true     # true/false
+
+# (OC) Add or remove newline between method declaration and '{'.
+nl_oc_mdef_brace                = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove newline between Objective-C block signature and '{'.
+nl_oc_block_brace               = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove blank line before '@interface' statement.
+nl_oc_before_interface          = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove blank line before '@implementation' statement.
+nl_oc_before_implementation     = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove blank line before '@end' statement.
+nl_oc_before_end                = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove newline between '@interface' and '{'.
+nl_oc_interface_brace           = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove newline between '@implementation' and '{'.
+nl_oc_implementation_brace      = ignore   # ignore/add/remove/force
+
+# Add or remove newlines at the start of the file.
+nl_start_of_file                = remove   # ignore/add/remove/force
+
+# The minimum number of newlines at the start of the file (only used if
+# nl_start_of_file is 'add' or 'force').
+nl_start_of_file_min            = 0        # unsigned number
+
+# Add or remove newline at the end of the file.
+nl_end_of_file                  = force    # ignore/add/remove/force
+
+# The minimum number of newlines at the end of the file (only used if
+# nl_end_of_file is 'add' or 'force').
+nl_end_of_file_min              = 1        # unsigned number
+
+# Add or remove newline between '=' and '{'.
+nl_assign_brace                 = ignore    # ignore/add/remove/force
+
+# (D) Add or remove newline between '=' and '['.
+nl_assign_square                = ignore   # ignore/add/remove/force
+
+# Add or remove newline between '[]' and '{'.
+nl_tsquare_brace                = ignore   # ignore/add/remove/force
+
+# (D) Add or remove newline after '= ['. Will also affect the newline before
+# the ']'.
+nl_after_square_assign          = ignore   # ignore/add/remove/force
+
+# Add or remove newline between a function call's ')' and '{', as in
+# 'list_for_each(item, &list) { }'.
+nl_fcall_brace                  = ignore   # ignore/add/remove/force
+
+# Add or remove newline between 'enum' and '{'.
+nl_enum_brace                   = remove   # ignore/add/remove/force
+
+# Add or remove newline between 'enum' and 'class'.
+nl_enum_class                   = ignore   # ignore/add/remove/force
+
+# Add or remove newline between 'enum class' and the identifier.
+nl_enum_class_identifier        = ignore   # ignore/add/remove/force
+
+# Add or remove newline between 'enum class' type and ':'.
+nl_enum_identifier_colon        = ignore   # ignore/add/remove/force
+
+# Add or remove newline between 'enum class identifier :' and type.
+nl_enum_colon_type              = ignore   # ignore/add/remove/force
+
+# Add or remove newline between 'struct and '{'.
+nl_struct_brace                 = remove   # ignore/add/remove/force
+
+# Add or remove newline between 'union' and '{'.
+nl_union_brace                  = remove   # ignore/add/remove/force
+
+# Add or remove newline between 'if' and '{'.
+nl_if_brace                     = remove   # ignore/add/remove/force
+
+# Add or remove newline between '}' and 'else'.
+nl_brace_else                   = remove   # ignore/add/remove/force
+
+# Add or remove newline between 'else if' and '{'. If set to ignore,
+# nl_if_brace is used instead.
+nl_elseif_brace                 = ignore   # ignore/add/remove/force
+
+# Add or remove newline between 'else' and '{'.
+nl_else_brace                   = remove   # ignore/add/remove/force
+
+# Add or remove newline between 'else' and 'if'.
+nl_else_if                      = remove   # ignore/add/remove/force
+
+# Add or remove newline before '{' opening brace
+nl_before_opening_brace_func_class_def = force   # ignore/add/remove/force
+
+# Add or remove newline before 'if'/'else if' closing parenthesis.
+nl_before_if_closing_paren      = remove   # ignore/add/remove/force
+
+# Add or remove newline between '}' and 'finally'.
+nl_brace_finally                = ignore   # ignore/add/remove/force
+
+# Add or remove newline between 'finally' and '{'.
+nl_finally_brace                = ignore   # ignore/add/remove/force
+
+# Add or remove newline between 'try' and '{'.
+nl_try_brace                    = ignore   # ignore/add/remove/force
+
+# Add or remove newline between get/set and '{'.
+nl_getset_brace                 = ignore   # ignore/add/remove/force
+
+# Add or remove newline between 'for' and '{'.
+nl_for_brace                    = remove   # ignore/add/remove/force
+
+# Add or remove newline before the '{' of a 'catch' statement, as in
+# 'catch (decl) <here> {'.
+nl_catch_brace                  = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove newline before the '{' of a '@catch' statement, as in
+# '@catch (decl) <here> {'. If set to ignore, nl_catch_brace is used.
+nl_oc_catch_brace               = ignore   # ignore/add/remove/force
+
+# Add or remove newline between '}' and 'catch'.
+nl_brace_catch                  = ignore   # ignore/add/remove/force
+
+# (OC) Add or remove newline between '}' and '@catch'. If set to ignore,
+# nl_brace_catch is used.
+nl_oc_brace_catch               = ignore   # ignore/add/remove/force
+
+# Add or remove newline between '}' and ']'.
+nl_brace_square                 = ignore   # ignore/add/remove/force
+
+# Add or remove newline between '}' and ')' in a function invocation.
+nl_brace_fparen                 = ignore   # ignore/add/remove/force
+
+# Add or remove newline between 'while' and '{'.
+nl_while_brace                  = remove   # ignore/add/remove/force
+
+# (D) Add or remove newline between 'scope (x)' and '{'.
+nl_scope_brace                  = ignore   # ignore/add/remove/force
+
+# (D) Add or remove newline between 'unittest' and '{'.
+nl_unittest_brace               = ignore   # ignore/add/remove/force
+
+# (D) Add or remove newline between 'version (x)' and '{'.
+nl_version_brace                = ignore   # ignore/add/remove/force
+
+# (C#) Add or remove newline between 'using' and '{'.
+nl_using_brace                  = ignore   # ignore/add/remove/force
+
+# Add or remove newline between two open or close braces. Due to general
+# newline/brace handling, REMOVE may not work.
+nl_brace_brace                  = ignore   # ignore/add/remove/force
+
+# Add or remove newline between 'do' and '{'.
+nl_do_brace                     = remove   # ignore/add/remove/force
+
+# Add or remove newline between '}' and 'while' of 'do' statement.
+nl_brace_while                  = remove   # ignore/add/remove/force
+
+# Add or remove newline between 'switch' and '{'.
+nl_switch_brace                 = remove   # ignore/add/remove/force
+
+# Add or remove newline between 'synchronized' and '{'.
+nl_synchronized_brace           = ignore   # ignore/add/remove/force
+
+# Add a newline between ')' and '{' if the ')' is on a different line than the
+# if/for/etc.
+#
+# Overrides nl_for_brace, nl_if_brace, nl_switch_brace, nl_while_switch and
+# nl_catch_brace.
+nl_multi_line_cond              = false    # true/false
+
+# Add a newline after '(' if an if/for/while/switch condition spans multiple
+# lines
+nl_multi_line_sparen_open       = ignore   # ignore/add/remove/force
+
+# Add a newline before ')' if an if/for/while/switch condition spans multiple
+# lines. Overrides nl_before_if_closing_paren if both are specified.
+nl_multi_line_sparen_close      = ignore   # ignore/add/remove/force
+
+# Force a newline in a define after the macro name for multi-line defines.
+nl_multi_line_define            = false    # true/false
+
+# Whether to add a newline before 'case', and a blank line before a 'case'
+# statement that follows a ';' or '}'.
+nl_before_case                  = false    # true/false
+
+# Whether to add a newline after a 'case' statement.
+nl_after_case                   = true     # true/false
+
+# Add or remove newline between a case ':' and '{'.
+#
+# Overrides nl_after_case.
+nl_case_colon_brace             = remove   # ignore/add/remove/force
+
+# Add or remove newline between ')' and 'throw'.
+nl_before_throw                 = ignore   # ignore/add/remove/force
+
+# Add or remove newline between 'namespace' and '{'.
+nl_namespace_brace              = ignore   # ignore/add/remove/force
+
+# Add or remove newline after 'template<...>' of a template class.
+nl_template_class               = ignore   # ignore/add/remove/force
+
+# Add or remove newline after 'template<...>' of a template class declaration.
+#
+# Overrides nl_template_class.
+nl_template_class_decl          = ignore   # ignore/add/remove/force
+
+# Add or remove newline after 'template<>' of a specialized class declaration.
+#
+# Overrides nl_template_class_decl.
+nl_template_class_decl_special  = ignore   # ignore/add/remove/force
+
+# Add or remove newline after 'template<...>' of a template class definition.
+#
+# Overrides nl_template_class.
+nl_template_class_def           = ignore   # ignore/add/remove/force
+
+# Add or remove newline after 'template<>' of a specialized class definition.
+#
+# Overrides nl_template_class_def.
+nl_template_class_def_special   = ignore   # ignore/add/remove/force
+
+# Add or remove newline after 'template<...>' of a template function.
+nl_template_func                = ignore   # ignore/add/remove/force
+
+# Add or remove newline after 'template<...>' of a template function
+# declaration.
+#
+# Overrides nl_template_func.
+nl_template_func_decl           = ignore   # ignore/add/remove/force
+
+# Add or remove newline after 'template<>' of a specialized function
+# declaration.
+#
+# Overrides nl_template_func_decl.
+nl_template_func_decl_special   = ignore   # ignore/add/remove/force
+
+# Add or remove newline after 'template<...>' of a template function
+# definition.
+#
+# Overrides nl_template_func.
+nl_template_func_def            = ignore   # ignore/add/remove/force
+
+# Add or remove newline after 'template<>' of a specialized function
+# definition.
+#
+# Overrides nl_template_func_def.
+nl_template_func_def_special    = ignore   # ignore/add/remove/force
+
+# Add or remove newline after 'template<...>' of a template variable.
+nl_template_var                 = ignore   # ignore/add/remove/force
+
+# Add or remove newline between 'template<...>' and 'using' of a templated
+# type alias.
+nl_template_using               = ignore   # ignore/add/remove/force
+
+# Add or remove newline between 'class' and '{'.
+nl_class_brace                  = ignore   # ignore/add/remove/force
+
+# Add or remove newline before or after (depending on pos_class_comma,
+# may not be IGNORE) each',' in the base class list.
+nl_class_init_args              = ignore   # ignore/add/remove/force
+
+# Add or remove newline after each ',' in the constructor member
+# initialization. Related to nl_constr_colon, pos_constr_colon and
+# pos_constr_comma.
+nl_constr_init_args             = ignore   # ignore/add/remove/force
+
+# Add or remove newline before first element, after comma, and after last
+# element, in 'enum'.
+nl_enum_own_lines               = ignore    # ignore/add/remove/force
+
+# Add or remove newline between return type and function name in a function
+# definition.
+# might be modified by nl_func_leave_one_liners
+nl_func_type_name               = force     # ignore/add/remove/force
+
+# Add or remove newline between return type and function name inside a class
+# definition. If set to ignore, nl_func_type_name or nl_func_proto_type_name
+# is used instead.
+nl_func_type_name_class         = ignore   # ignore/add/remove/force
+
+# Add or remove newline between class specification and '::'
+# in 'void A::f() { }'. Only appears in separate member implementation (does
+# not appear with in-line implementation).
+nl_func_class_scope             = ignore   # ignore/add/remove/force
+
+# Add or remove newline between function scope and name, as in
+# 'void A :: <here> f() { }'.
+nl_func_scope_name              = ignore   # ignore/add/remove/force
+
+# Add or remove newline between return type and function name in a prototype.
+nl_func_proto_type_name         = remove   # ignore/add/remove/force
+
+# Add or remove newline between a function name and the opening '(' in the
+# declaration.
+nl_func_paren                   = remove   # ignore/add/remove/force
+
+# Overrides nl_func_paren for functions with no parameters.
+nl_func_paren_empty             = ignore   # ignore/add/remove/force
+
+# Add or remove newline between a function name and the opening '(' in the
+# definition.
+nl_func_def_paren               = remove   # ignore/add/remove/force
+
+# Overrides nl_func_def_paren for functions with no parameters.
+nl_func_def_paren_empty         = ignore   # ignore/add/remove/force
+
+# Add or remove newline between a function name and the opening '(' in the
+# call.
+nl_func_call_paren              = remove   # ignore/add/remove/force
+
+# Overrides nl_func_call_paren for functions with no parameters.
+nl_func_call_paren_empty        = ignore   # ignore/add/remove/force
+
+# Add or remove newline after '(' in a function declaration.
+nl_func_decl_start              = ignore   # ignore/add/remove/force
+
+# Add or remove newline after '(' in a function definition.
+nl_func_def_start               = ignore   # ignore/add/remove/force
+
+# Overrides nl_func_decl_start when there is only one parameter.
+nl_func_decl_start_single       = ignore   # ignore/add/remove/force
+
+# Overrides nl_func_def_start when there is only one parameter.
+nl_func_def_start_single        = ignore   # ignore/add/remove/force
+
+# Whether to add a newline after '(' in a function declaration if '(' and ')'
+# are in different lines. If false, nl_func_decl_start is used instead.
+nl_func_decl_start_multi_line   = false    # true/false
+
+# Whether to add a newline after '(' in a function definition if '(' and ')'
+# are in different lines. If false, nl_func_def_start is used instead.
+nl_func_def_start_multi_line    = false    # true/false
+
+# Add or remove newline after each ',' in a function declaration.
+nl_func_decl_args               = ignore   # ignore/add/remove/force
+
+# Add or remove newline after each ',' in a function definition.
+nl_func_def_args                = ignore   # ignore/add/remove/force
+
+# Add or remove newline after each ',' in a function call.
+nl_func_call_args               = ignore   # ignore/add/remove/force
+
+# Whether to add a newline after each ',' in a function declaration if '('
+# and ')' are in different lines. If false, nl_func_decl_args is used instead.
+nl_func_decl_args_multi_line    = false    # true/false
+
+# Whether to add a newline after each ',' in a function definition if '('
+# and ')' are in different lines. If false, nl_func_def_args is used instead.
+nl_func_def_args_multi_line     = false    # true/false
+
+# Add or remove newline before the ')' in a function declaration.
+nl_func_decl_end                = remove   # ignore/add/remove/force
+
+# Add or remove newline before the ')' in a function definition.
+nl_func_def_end                 = remove   # ignore/add/remove/force
+
+# Overrides nl_func_decl_end when there is only one parameter.
+nl_func_decl_end_single         = ignore   # ignore/add/remove/force
+
+# Overrides nl_func_def_end when there is only one parameter.
+nl_func_def_end_single          = ignore   # ignore/add/remove/force
+
+# Whether to add a newline before ')' in a function declaration if '(' and ')'
+# are in different lines. If false, nl_func_decl_end is used instead.
+nl_func_decl_end_multi_line     = false    # true/false
+
+# Whether to add a newline before ')' in a function definition if '(' and ')'
+# are in different lines. If false, nl_func_def_end is used instead.
+nl_func_def_end_multi_line      = false    # true/false
+
+# Add or remove newline between '()' in a function declaration.
+nl_func_decl_empty              = remove   # ignore/add/remove/force
+
+# Add or remove newline between '()' in a function definition.
+nl_func_def_empty               = remove   # ignore/add/remove/force
+
+# Add or remove newline between '()' in a function call.
+nl_func_call_empty              = remove   # ignore/add/remove/force
+
+# Whether to add a newline after '(' in a function call,
+# has preference over nl_func_call_start_multi_line.
+nl_func_call_start              = ignore   # ignore/add/remove/force
+
+# Whether to add a newline before ')' in a function call.
+nl_func_call_end                = remove   # ignore/add/remove/force
+
+# Whether to add a newline after '(' in a function call if '(' and ')' are in
+# different lines.
+nl_func_call_start_multi_line   = false    # true/false
+
+# Whether to add a newline after each ',' in a function call if '(' and ')'
+# are in different lines.
+nl_func_call_args_multi_line    = false    # true/false
+
+# Whether to add a newline before ')' in a function call if '(' and ')' are in
+# different lines.
+nl_func_call_end_multi_line     = false    # true/false
+
+# Whether to respect nl_func_call_XXX option incase of closure args.
+nl_func_call_args_multi_line_ignore_closures = true    # true/false
+
+# Whether to add a newline after '<' of a template parameter list.
+nl_template_start               = false    # true/false
+
+# Whether to add a newline after each ',' in a template parameter list.
+nl_template_args                = false    # true/false
+
+# Whether to add a newline before '>' of a template parameter list.
+nl_template_end                 = false    # true/false
+
+# (OC) Whether to put each Objective-C message parameter on a separate line.
+# See nl_oc_msg_leave_one_liner.
+nl_oc_msg_args                  = false    # true/false
+
+# Add or remove newline between function signature and '{'.
+nl_fdef_brace                   = force    # ignore/add/remove/force
+
+# Add or remove newline between function signature and '{',
+# if signature ends with ')'. Overrides nl_fdef_brace.
+nl_fdef_brace_cond              = force    # ignore/add/remove/force
+
+# Add or remove newline between C++11 lambda signature and '{'.
+nl_cpp_ldef_brace               = ignore   # ignore/add/remove/force
+
+# Add or remove newline between 'return' and the return expression.
+nl_return_expr                  = remove   # ignore/add/remove/force
+
+# Whether to add a newline after semicolons, except in 'for' statements.
+nl_after_semicolon              = false    # true/false
+
+# (Java) Add or remove newline between the ')' and '{{' of the double brace
+# initializer.
+nl_paren_dbrace_open            = ignore   # ignore/add/remove/force
+
+# Whether to add a newline after the type in an unnamed temporary
+# direct-list-initialization.
+nl_type_brace_init_lst          = ignore   # ignore/add/remove/force
+
+# Whether to add a newline after the open brace in an unnamed temporary
+# direct-list-initialization.
+nl_type_brace_init_lst_open     = ignore   # ignore/add/remove/force
+
+# Whether to add a newline before the close brace in an unnamed temporary
+# direct-list-initialization.
+nl_type_brace_init_lst_close    = ignore   # ignore/add/remove/force
+
+# Whether to add a newline before '{'.
+nl_before_brace_open            = false    # true/false
+
+# Whether to add a newline after '{'. This also adds a newline before the
+# matching '}'.
+nl_after_brace_open             = true     # true/false
+
+# Whether to add a newline between the open brace and a trailing single-line
+# comment. Requires nl_after_brace_open=true.
+nl_after_brace_open_cmt         = false    # true/false
+
+# Whether to add a newline after a virtual brace open with a non-empty body.
+# These occur in un-braced if/while/do/for statement bodies.
+nl_after_vbrace_open            = false    # true/false
+
+# Whether to add a newline after a virtual brace open with an empty body.
+# These occur in un-braced if/while/do/for statement bodies.
+nl_after_vbrace_open_empty      = false    # true/false
+
+# Whether to add a newline after '}'. Does not apply if followed by a
+# necessary ';'.
+nl_after_brace_close            = true     # true/false
+
+# Whether to add a newline after a virtual brace close,
+# as in 'if (foo) a++; <here> return;'.
+nl_after_vbrace_close           = false    # true/false
+
+# Add or remove newline between the close brace and identifier,
+# as in 'struct { int a; } <here> b;'. Affects enumerations, unions and
+# structures. If set to ignore, uses nl_after_brace_close.
+nl_brace_struct_var             = remove   # ignore/add/remove/force
+
+# Whether to alter newlines in '#define' macros.
+nl_define_macro                 = false    # true/false
+
+# Whether to alter newlines between consecutive parenthesis closes. The number
+# of closing parentheses in a line will depend on respective open parenthesis
+# lines.
+nl_squeeze_paren_close          = true     # true/false
+
+# Whether to remove blanks after '#ifxx' and '#elxx', or before '#elxx' and
+# '#endif'. Does not affect top-level #ifdefs.
+nl_squeeze_ifdef                = true     # true/false
+
+# Makes the nl_squeeze_ifdef option affect the top-level #ifdefs as well.
+nl_squeeze_ifdef_top_level      = false    # true/false
+
+# Add or remove blank line before 'if'.
+nl_before_if                    = ignore   # ignore/add/remove/force
+
+# Add or remove blank line after 'if' statement. Add/Force work only if the
+# next token is not a closing brace.
+nl_after_if                     = ignore   # ignore/add/remove/force
+
+# Add or remove blank line before 'for'.
+nl_before_for                   = ignore   # ignore/add/remove/force
+
+# Add or remove blank line after 'for' statement.
+nl_after_for                    = ignore   # ignore/add/remove/force
+
+# Add or remove blank line before 'while'.
+nl_before_while                 = ignore   # ignore/add/remove/force
+
+# Add or remove blank line after 'while' statement.
+nl_after_while                  = ignore   # ignore/add/remove/force
+
+# Add or remove blank line before 'switch'.
+nl_before_switch                = ignore   # ignore/add/remove/force
+
+# Add or remove blank line after 'switch' statement.
+nl_after_switch                 = ignore   # ignore/add/remove/force
+
+# Add or remove blank line before 'synchronized'.
+nl_before_synchronized          = ignore   # ignore/add/remove/force
+
+# Add or remove blank line after 'synchronized' statement.
+nl_after_synchronized           = ignore   # ignore/add/remove/force
+
+# Add or remove blank line before 'do'.
+nl_before_do                    = ignore   # ignore/add/remove/force
+
+# Add or remove blank line after 'do/while' statement.
+nl_after_do                     = ignore   # ignore/add/remove/force
+
+# Ignore nl_before_{if,for,switch,do,synchronized} if the control
+# statement is immediately after a case statement.
+# if nl_before_{if,for,switch,do} is set to remove, this option
+# does nothing.
+nl_before_ignore_after_case     = false    # true/false
+
+# Whether to put a blank line before 'return' statements, unless after an open
+# brace.
+nl_before_return                = false    # true/false
+
+# Whether to put a blank line after 'return' statements, unless followed by a
+# close brace.
+nl_after_return                 = false    # true/false
+
+# Whether to put a blank line before a member '.' or '->' operators.
+nl_before_member                = ignore   # ignore/add/remove/force
+
+# (Java) Whether to put a blank line after a member '.' or '->' operators.
+nl_after_member                 = ignore   # ignore/add/remove/force
+
+# Whether to double-space commented-entries in 'struct'/'union'/'enum'.
+nl_ds_struct_enum_cmt           = false    # true/false
+
+# Whether to force a newline before '}' of a 'struct'/'union'/'enum'.
+# (Lower priority than eat_blanks_before_close_brace.)
+nl_ds_struct_enum_close_brace   = false    # true/false
+
+# Add or remove newline before or after (depending on pos_class_colon) a class
+# colon, as in 'class Foo <here> : <or here> public Bar'.
+nl_class_colon                  = ignore   # ignore/add/remove/force
+
+# Add or remove newline around a class constructor colon. The exact position
+# depends on nl_constr_init_args, pos_constr_colon and pos_constr_comma.
+nl_constr_colon                 = ignore   # ignore/add/remove/force
+
+# Whether to collapse a two-line namespace, like 'namespace foo\n{ decl; }'
+# into a single line. If true, prevents other brace newline rules from turning
+# such code into four lines.
+nl_namespace_two_to_one_liner   = false    # true/false
+
+# Whether to remove a newline in simple unbraced if statements, turning them
+# into one-liners, as in 'if(b)\n i++;' => 'if(b) i++;'.
+nl_create_if_one_liner          = false    # true/false
+
+# Whether to remove a newline in simple unbraced for statements, turning them
+# into one-liners, as in 'for (...)\n stmt;' => 'for (...) stmt;'.
+nl_create_for_one_liner         = false    # true/false
+
+# Whether to remove a newline in simple unbraced while statements, turning
+# them into one-liners, as in 'while (expr)\n stmt;' => 'while (expr) stmt;'.
+nl_create_while_one_liner       = false    # true/false
+
+# Whether to collapse a function definition whose body (not counting braces)
+# is only one line so that the entire definition (prototype, braces, body) is
+# a single line.
+nl_create_func_def_one_liner    = false    # true/false
+
+# Whether to collapse a function definition whose body (not counting braces)
+# is only one line so that the entire definition (prototype, braces, body) is
+# a single line.
+nl_create_list_one_liner        = false    # true/false
+
+# Whether to split one-line simple unbraced if statements into two lines by
+# adding a newline, as in 'if(b) <here> i++;'.
+nl_split_if_one_liner           = false    # true/false
+
+# Whether to split one-line simple unbraced for statements into two lines by
+# adding a newline, as in 'for (...) <here> stmt;'.
+nl_split_for_one_liner          = false    # true/false
+
+# Whether to split one-line simple unbraced while statements into two lines by
+# adding a newline, as in 'while (expr) <here> stmt;'.
+nl_split_while_one_liner        = false    # true/false
+
+# Don't add a newline before a cpp-comment in a parameter list of a function
+# call.
+donot_add_nl_before_cpp_comment = false    # true/false
+
+#
+# Blank line options
+#
+
+# The maximum number of consecutive newlines (3 = 2 blank lines).
+nl_max                          = 2        # unsigned number
+
+# The maximum number of consecutive newlines in a function.
+nl_max_blank_in_func            = 2        # unsigned number
+
+# The number of newlines inside an empty function body.
+# This option overrides eat_blanks_after_open_brace and
+# eat_blanks_before_close_brace, but is ignored when
+# nl_collapse_empty_body=true
+nl_inside_empty_func            = 0        # unsigned number
+
+# The number of newlines before a function prototype.
+nl_before_func_body_proto       = 0        # unsigned number
+
+# The number of newlines before a multi-line function definition.
+nl_before_func_body_def         = 0        # unsigned number
+
+# The number of newlines before a class constructor/destructor prototype.
+nl_before_func_class_proto      = 0        # unsigned number
+
+# The number of newlines before a class constructor/destructor definition.
+nl_before_func_class_def        = 0        # unsigned number
+
+# The number of newlines after a function prototype.
+nl_after_func_proto             = 0        # unsigned number
+
+# The number of newlines after a function prototype, if not followed by
+# another function prototype.
+nl_after_func_proto_group       = 0        # unsigned number
+
+# The number of newlines after a class constructor/destructor prototype.
+nl_after_func_class_proto       = 0        # unsigned number
+
+# The number of newlines after a class constructor/destructor prototype,
+# if not followed by another constructor/destructor prototype.
+nl_after_func_class_proto_group = 0        # unsigned number
+
+# Whether one-line method definitions inside a class body should be treated
+# as if they were prototypes for the purposes of adding newlines.
+#
+# Requires nl_class_leave_one_liners=true. Overrides nl_before_func_body_def
+# and nl_before_func_class_def for one-liners.
+nl_class_leave_one_liner_groups = false    # true/false
+
+# The number of newlines after '}' of a multi-line function body.
+nl_after_func_body              = 2        # unsigned number
+
+# The number of newlines after '}' of a multi-line function body in a class
+# declaration. Also affects class constructors/destructors.
+#
+# Overrides nl_after_func_body.
+nl_after_func_body_class        = 2        # unsigned number
+
+# The number of newlines after '}' of a single line function body. Also
+# affects class constructors/destructors.
+#
+# Overrides nl_after_func_body and nl_after_func_body_class.
+nl_after_func_body_one_liner    = 2        # unsigned number
+
+# The number of blank lines after a block of variable definitions at the top
+# of a function body.
+#
+# 0: No change (default).
+nl_func_var_def_blk             = 1        # unsigned number
+
+# The number of newlines before a block of typedefs. If nl_after_access_spec
+# is non-zero, that option takes precedence.
+#
+# 0: No change (default).
+nl_typedef_blk_start            = 1        # unsigned number
+
+# The number of newlines after a block of typedefs.
+#
+# 0: No change (default).
+nl_typedef_blk_end              = 1        # unsigned number
+
+# The maximum number of consecutive newlines within a block of typedefs.
+#
+# 0: No change (default).
+nl_typedef_blk_in               = 0        # unsigned number
+
+# The number of newlines before a block of variable definitions not at the top
+# of a function body. If nl_after_access_spec is non-zero, that option takes
+# precedence.
+#
+# 0: No change (default).
+nl_var_def_blk_start            = 0        # unsigned number
+
+# The number of newlines after a block of variable definitions not at the top
+# of a function body.
+#
+# 0: No change (default).
+nl_var_def_blk_end              = 1        # unsigned number
+
+# The maximum number of consecutive newlines within a block of variable
+# definitions.
+#
+# 0: No change (default).
+nl_var_def_blk_in               = 0        # unsigned number
+
+# The minimum number of newlines before a multi-line comment.
+# Doesn't apply if after a brace open or another multi-line comment.
+nl_before_block_comment         = 0        # unsigned number
+
+# The minimum number of newlines before a single-line C comment.
+# Doesn't apply if after a brace open or other single-line C comments.
+nl_before_c_comment             = 0        # unsigned number
+
+# The minimum number of newlines before a CPP comment.
+# Doesn't apply if after a brace open or other CPP comments.
+nl_before_cpp_comment           = 0        # unsigned number
+
+# Whether to force a newline after a multi-line comment.
+nl_after_multiline_comment      = false    # true/false
+
+# Whether to force a newline after a label's colon.
+nl_after_label_colon            = true     # true/false
+
+# The number of newlines before a struct definition.
+nl_before_struct                = 1        # unsigned number
+
+# The number of newlines after '}' or ';' of a struct/enum/union definition.
+nl_after_struct                 = 1        # unsigned number
+
+# The number of newlines before a class definition.
+nl_before_class                 = 0        # unsigned number
+
+# The number of newlines after '}' or ';' of a class definition.
+nl_after_class                  = 0        # unsigned number
+
+# The number of newlines before a namespace.
+nl_before_namespace             = 0        # unsigned number
+
+# The number of newlines after '{' of a namespace. This also adds newlines
+# before the matching '}'.
+#
+# 0: Apply eat_blanks_after_open_brace or eat_blanks_before_close_brace if
+#     applicable, otherwise no change.
+#
+# Overrides eat_blanks_after_open_brace and eat_blanks_before_close_brace.
+nl_inside_namespace             = 0        # unsigned number
+
+# The number of newlines after '}' of a namespace.
+nl_after_namespace              = 0        # unsigned number
+
+# The number of newlines before an access specifier label. This also includes
+# the Qt-specific 'signals:' and 'slots:'. Will not change the newline count
+# if after a brace open.
+#
+# 0: No change (default).
+nl_before_access_spec           = 0        # unsigned number
+
+# The number of newlines after an access specifier label. This also includes
+# the Qt-specific 'signals:' and 'slots:'. Will not change the newline count
+# if after a brace open.
+#
+# 0: No change (default).
+#
+# Overrides nl_typedef_blk_start and nl_var_def_blk_start.
+nl_after_access_spec            = 0        # unsigned number
+
+# The number of newlines between a function definition and the function
+# comment, as in '// comment\n <here> void foo() {...}'.
+#
+# 0: No change (default).
+nl_comment_func_def             = 0        # unsigned number
+
+# The number of newlines after a try-catch-finally block that isn't followed
+# by a brace close.
+#
+# 0: No change (default).
+nl_after_try_catch_finally      = 0        # unsigned number
+
+# (C#) The number of newlines before and after a property, indexer or event
+# declaration.
+#
+# 0: No change (default).
+nl_around_cs_property           = 0        # unsigned number
+
+# (C#) The number of newlines between the get/set/add/remove handlers.
+#
+# 0: No change (default).
+nl_between_get_set              = 0        # unsigned number
+
+# (C#) Add or remove newline between property and the '{'.
+nl_property_brace               = ignore   # ignore/add/remove/force
+
+# Whether to remove blank lines after '{'.
+eat_blanks_after_open_brace     = false    # true/false
+
+# Whether to remove blank lines before '}'.
+eat_blanks_before_close_brace   = false    # true/false
+
+# How aggressively to remove extra newlines not in preprocessor.
+#
+# 0: No change (default)
+# 1: Remove most newlines not handled by other config
+# 2: Remove all newlines and reformat completely by config
+nl_remove_extra_newlines        = 0        # unsigned number
+
+# (Java) Add or remove newline after an annotation statement. Only affects
+# annotations that are after a newline.
+nl_after_annotation             = ignore   # ignore/add/remove/force
+
+# (Java) Add or remove newline between two annotations.
+nl_between_annotation           = ignore   # ignore/add/remove/force
+
+# The number of newlines before a whole-file #ifdef.
+#
+# 0: No change (default).
+nl_before_whole_file_ifdef      = 2        # unsigned number
+
+# The number of newlines after a whole-file #ifdef.
+#
+# 0: No change (default).
+nl_after_whole_file_ifdef       = 0        # unsigned number
+
+# The number of newlines before a whole-file #endif.
+#
+# 0: No change (default).
+nl_before_whole_file_endif      = 2        # unsigned number
+
+# The number of newlines after a whole-file #endif.
+#
+# 0: No change (default).
+nl_after_whole_file_endif       = 2        # unsigned number
+
+#
+# Positioning options
+#
+
+# The position of arithmetic operators in wrapped expressions.
+pos_arith                       = trail    # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force
+
+# The position of assignment in wrapped expressions. Do not affect '='
+# followed by '{'.
+pos_assign                      = trail    # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force
+
+# The position of Boolean operators in wrapped expressions.
+pos_bool                        = trail    # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force
+
+# The position of comparison operators in wrapped expressions.
+pos_compare                     = trail    # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force
+
+# The position of conditional operators, as in the '?' and ':' of
+# 'expr ? stmt : stmt', in wrapped expressions.
+pos_conditional                 = trail    # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force
+
+# The position of the comma in wrapped expressions.
+pos_comma                       = trail    # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force
+
+# The position of the comma in enum entries.
+pos_enum_comma                  = trail    # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force
+
+# The position of the comma in the base class list if there is more than one
+# line. Affects nl_class_init_args.
+pos_class_comma                 = ignore   # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force
+
+# The position of the comma in the constructor initialization list.
+# Related to nl_constr_colon, nl_constr_init_args and pos_constr_colon.
+pos_constr_comma                = ignore   # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force
+
+# The position of trailing/leading class colon, between class and base class
+# list. Affects nl_class_colon.
+pos_class_colon                 = ignore   # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force
+
+# The position of colons between constructor and member initialization.
+# Related to nl_constr_colon, nl_constr_init_args and pos_constr_comma.
+pos_constr_colon                = ignore   # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force
+
+# The position of shift operators in wrapped expressions.
+pos_shift                       = ignore   # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force
+
+#
+# Line splitting options
+#
+
+# Try to limit code width to N columns.
+code_width                      = 256      # unsigned number
+
+# Whether to fully split long 'for' statements at semi-colons.
+ls_for_split_full               = true     # true/false
+
+# Whether to fully split long function prototypes/calls at commas.
+# The option ls_code_width has priority over the option ls_func_split_full.
+ls_func_split_full              = false    # true/false
+
+# Whether to split lines as close to code_width as possible and ignore some
+# groupings.
+# The option ls_code_width has priority over the option ls_func_split_full.
+ls_code_width                   = false    # true/false
+
+#
+# Code alignment options (not left column spaces/tabs)
+#
+
+# Whether to keep non-indenting tabs.
+align_keep_tabs                 = false    # true/false
+
+# Whether to use tabs for aligning.
+align_with_tabs                 = false    # true/false
+
+# Whether to bump out to the next tab when aligning.
+align_on_tabstop                = true     # true/false
+
+# Whether to right-align numbers.
+align_number_right              = true     # true/false
+
+# Whether to keep whitespace not required for alignment.
+align_keep_extra_space          = false    # true/false
+
+# Whether to align variable definitions in prototypes and functions.
+align_func_params               = false    # true/false
+
+# The span for aligning parameter definitions in function on parameter name.
+#
+# 0: Don't align (default).
+align_func_params_span          = 0        # unsigned number
+
+# The threshold for aligning function parameter definitions.
+# Use a negative number for absolute thresholds.
+#
+# 0: No limit (default).
+align_func_params_thresh        = 0        # number
+
+# The gap for aligning function parameter definitions.
+align_func_params_gap           = 1        # unsigned number
+
+# The span for aligning constructor value.
+#
+# 0: Don't align (default).
+align_constr_value_span         = 0        # unsigned number
+
+# The threshold for aligning constructor value.
+# Use a negative number for absolute thresholds.
+#
+# 0: No limit (default).
+align_constr_value_thresh       = 0        # number
+
+# The gap for aligning constructor value.
+align_constr_value_gap          = 0        # unsigned number
+
+# Whether to align parameters in single-line functions that have the same
+# name. The function names must already be aligned with each other.
+align_same_func_call_params     = false    # true/false
+
+# The span for aligning function-call parameters for single line functions.
+#
+# 0: Don't align (default).
+align_same_func_call_params_span = 1        # unsigned number
+
+# The threshold for aligning function-call parameters for single line
+# functions.
+# Use a negative number for absolute thresholds.
+#
+# 0: No limit (default).
+align_same_func_call_params_thresh = 0        # number
+
+# The span for aligning variable definitions.
+#
+# 0: Don't align (default).
+align_var_def_span              = 0        # unsigned number
+
+# How to consider (or treat) the '*' in the alignment of variable definitions.
+#
+# 0: Part of the type     'void *   foo;' (default)
+# 1: Part of the variable 'void     *foo;'
+# 2: Dangling             'void    *foo;'
+# Dangling: the '*' will not be taken into account when aligning.
+align_var_def_star_style        = 1        # unsigned number
+
+# How to consider (or treat) the '&' in the alignment of variable definitions.
+#
+# 0: Part of the type     'long &   foo;' (default)
+# 1: Part of the variable 'long     &foo;'
+# 2: Dangling             'long    &foo;'
+# Dangling: the '&' will not be taken into account when aligning.
+align_var_def_amp_style         = 1        # unsigned number
+
+# The threshold for aligning variable definitions.
+# Use a negative number for absolute thresholds.
+#
+# 0: No limit (default).
+align_var_def_thresh            = 0        # number
+
+# The gap for aligning variable definitions.
+align_var_def_gap               = 0        # unsigned number
+
+# Whether to align the colon in struct bit fields.
+align_var_def_colon             = false    # true/false
+
+# The gap for aligning the colon in struct bit fields.
+align_var_def_colon_gap         = 0        # unsigned number
+
+# Whether to align any attribute after the variable name.
+align_var_def_attribute         = false    # true/false
+
+# Whether to align inline struct/enum/union variable definitions.
+align_var_def_inline            = true    # true/false
+
+# The span for aligning on '=' in assignments.
+#
+# 0: Don't align (default).
+align_assign_span               = 0        # unsigned number
+
+# The span for aligning on '=' in function prototype modifier.
+#
+# 0: Don't align (default).
+align_assign_func_proto_span    = 0        # unsigned number
+
+# The threshold for aligning on '=' in assignments.
+# Use a negative number for absolute thresholds.
+#
+# 0: No limit (default).
+align_assign_thresh             = 0        # number
+
+# How to apply align_assign_span to function declaration "assignments", i.e.
+# 'virtual void foo() = 0' or '~foo() = {default|delete}'.
+#
+# 0: Align with other assignments (default)
+# 1: Align with each other, ignoring regular assignments
+# 2: Don't align
+align_assign_decl_func          = 0        # unsigned number
+
+# The span for aligning on '=' in enums.
+#
+# 0: Don't align (default).
+align_enum_equ_span             = 0        # unsigned number
+
+# The threshold for aligning on '=' in enums.
+# Use a negative number for absolute thresholds.
+#
+# 0: no limit (default).
+align_enum_equ_thresh           = 0        # number
+
+# The span for aligning class member definitions.
+#
+# 0: Don't align (default).
+align_var_class_span            = 0        # unsigned number
+
+# The threshold for aligning class member definitions.
+# Use a negative number for absolute thresholds.
+#
+# 0: No limit (default).
+align_var_class_thresh          = 0        # number
+
+# The gap for aligning class member definitions.
+align_var_class_gap             = 0        # unsigned number
+
+# The span for aligning struct/union member definitions.
+#
+# 0: Don't align (default).
+align_var_struct_span           = 0        # unsigned number
+
+# The threshold for aligning struct/union member definitions.
+# Use a negative number for absolute thresholds.
+#
+# 0: No limit (default).
+align_var_struct_thresh         = 0        # number
+
+# The gap for aligning struct/union member definitions.
+align_var_struct_gap            = 0        # unsigned number
+
+# The span for aligning struct initializer values.
+#
+# 0: Don't align (default).
+align_struct_init_span          = 0        # unsigned number
+
+# The span for aligning single-line typedefs.
+#
+# 0: Don't align (default).
+align_typedef_span              = 0        # unsigned number
+
+# The minimum space between the type and the synonym of a typedef.
+align_typedef_gap               = 1        # unsigned number
+
+# How to align typedef'd functions with other typedefs.
+#
+# 0: Don't mix them at all (default)
+# 1: Align the open parenthesis with the types
+# 2: Align the function type name with the other type names
+align_typedef_func              = 0        # unsigned number
+
+# How to consider (or treat) the '*' in the alignment of typedefs.
+#
+# 0: Part of the typedef type, 'typedef int * pint;' (default)
+# 1: Part of type name:        'typedef int   *pint;'
+# 2: Dangling:                 'typedef int  *pint;'
+# Dangling: the '*' will not be taken into account when aligning.
+align_typedef_star_style        = 1        # unsigned number
+
+# How to consider (or treat) the '&' in the alignment of typedefs.
+#
+# 0: Part of the typedef type, 'typedef int & intref;' (default)
+# 1: Part of type name:        'typedef int   &intref;'
+# 2: Dangling:                 'typedef int  &intref;'
+# Dangling: the '&' will not be taken into account when aligning.
+align_typedef_amp_style         = 1        # unsigned number
+
+# The span for aligning comments that end lines.
+#
+# 0: Don't align (default).
+align_right_cmt_span            = 0        # unsigned number
+
+# Minimum number of columns between preceding text and a trailing comment in
+# order for the comment to qualify for being aligned. Must be non-zero to have
+# an effect.
+align_right_cmt_gap             = 0        # unsigned number
+
+# If aligning comments, whether to mix with comments after '}' and #endif with
+# less than three spaces before the comment.
+align_right_cmt_mix             = false    # true/false
+
+# Whether to only align trailing comments that are at the same brace level.
+align_right_cmt_same_level      = false    # true/false
+
+# Minimum column at which to align trailing comments. Comments which are
+# aligned beyond this column, but which can be aligned in a lesser column,
+# may be "pulled in".
+#
+# 0: Ignore (default).
+align_right_cmt_at_col          = 0        # unsigned number
+
+# The span for aligning function prototypes.
+#
+# 0: Don't align (default).
+align_func_proto_span           = 0        # unsigned number
+
+# How to consider (or treat) the '*' in the alignment of function prototypes.
+#
+# 0: Part of the type     'void *   foo();' (default)
+# 1: Part of the function 'void     *foo();'
+# 2: Dangling             'void    *foo();'
+# Dangling: the '*' will not be taken into account when aligning.
+align_func_proto_star_style     = 0        # unsigned number
+
+# How to consider (or treat) the '&' in the alignment of function prototypes.
+#
+# 0: Part of the type     'long &   foo();' (default)
+# 1: Part of the function 'long     &foo();'
+# 2: Dangling             'long    &foo();'
+# Dangling: the '&' will not be taken into account when aligning.
+align_func_proto_amp_style      = 0        # unsigned number
+
+# The threshold for aligning function prototypes.
+# Use a negative number for absolute thresholds.
+#
+# 0: No limit (default).
+align_func_proto_thresh         = 0        # number
+
+# Minimum gap between the return type and the function name.
+align_func_proto_gap            = 1        # unsigned number
+
+# Whether to align function prototypes on the 'operator' keyword instead of
+# what follows.
+align_on_operator               = false    # true/false
+
+# Whether to mix aligning prototype and variable declarations. If true,
+# align_var_def_XXX options are used instead of align_func_proto_XXX options.
+align_mix_var_proto             = false    # true/false
+
+# Whether to align single-line functions with function prototypes.
+# Uses align_func_proto_span.
+align_single_line_func          = false    # true/false
+
+# Whether to align the open brace of single-line functions.
+# Requires align_single_line_func=true. Uses align_func_proto_span.
+align_single_line_brace         = false    # true/false
+
+# Gap for align_single_line_brace.
+align_single_line_brace_gap     = 1        # unsigned number
+
+# (OC) The span for aligning Objective-C message specifications.
+#
+# 0: Don't align (default).
+align_oc_msg_spec_span          = 0        # unsigned number
+
+# Whether to align macros wrapped with a backslash and a newline. This will
+# not work right if the macro contains a multi-line comment.
+align_nl_cont                   = false    # true/false
+
+# Whether to align macro functions and variables together.
+align_pp_define_together        = false    # true/false
+
+# The span for aligning on '#define' bodies.
+#
+# =0: Don't align (default)
+# >0: Number of lines (including comments) between blocks
+align_pp_define_span            = 0        # unsigned number
+
+# The minimum space between label and value of a preprocessor define.
+align_pp_define_gap             = 1        # unsigned number
+
+# Whether to align lines that start with '<<' with previous '<<'.
+#
+# Default: true
+align_left_shift                = false    # true/false
+
+# Whether to align comma-separated statements following '<<' (as used to
+# initialize Eigen matrices).
+align_eigen_comma_init          = false    # true/false
+
+# Whether to align text after 'asm volatile ()' colons.
+align_asm_colon                 = false    # true/false
+
+# (OC) Span for aligning parameters in an Objective-C message call
+# on the ':'.
+#
+# 0: Don't align.
+align_oc_msg_colon_span         = 0        # unsigned number
+
+# (OC) Whether to always align with the first parameter, even if it is too
+# short.
+align_oc_msg_colon_first        = false    # true/false
+
+# (OC) Whether to align parameters in an Objective-C '+' or '-' declaration
+# on the ':'.
+align_oc_decl_colon             = false    # true/false
+
+# (OC) Whether to not align parameters in an Objectve-C message call if first
+# colon is not on next line of the message call (the same way Xcode does
+# aligment)
+align_oc_msg_colon_xcode_like   = false    # true/false
+
+#
+# Comment modification options
+#
+
+# Try to wrap comments at N columns.
+cmt_width                       = 256      # unsigned number
+
+# How to reflow comments.
+#
+# 0: No reflowing (apart from the line wrapping due to cmt_width) (default)
+# 1: No touching at all
+# 2: Full reflow
+cmt_reflow_mode                 = 1        # unsigned number
+
+# Path to a file that contains regular expressions describing patterns for
+# which the end of one line and the beginning of the next will be folded into
+# the same sentence or paragraph during full comment reflow. The regular
+# expressions are described using ECMAScript syntax. The syntax for this
+# specification is as follows, where "..." indicates the custom regular
+# expression and "n" indicates the nth end_of_prev_line_regex and
+# beg_of_next_line_regex regular expression pair:
+#
+# end_of_prev_line_regex[1] = "...$"
+# beg_of_next_line_regex[1] = "^..."
+# end_of_prev_line_regex[2] = "...$"
+# beg_of_next_line_regex[2] = "^..."
+#             .
+#             .
+#             .
+# end_of_prev_line_regex[n] = "...$"
+# beg_of_next_line_regex[n] = "^..."
+#
+# Note that use of this option overrides the default reflow fold regular
+# expressions, which are internally defined as follows:
+#
+# end_of_prev_line_regex[1] = "[\w,\]\)]$"
+# beg_of_next_line_regex[1] = "^[\w,\[\(]"
+# end_of_prev_line_regex[2] = "\.$"
+# beg_of_next_line_regex[2] = "^[A-Z]"
+cmt_reflow_fold_regex_file      = ""         # string
+
+# Whether to indent wrapped lines to the start of the encompassing paragraph
+# during full comment reflow (cmt_reflow_mode = 2). Overrides the value
+# specified by cmt_sp_after_star_cont.
+#
+# Note that cmt_align_doxygen_javadoc_tags overrides this option for
+# paragraphs associated with javadoc tags
+cmt_reflow_indent_to_paragraph_start = false    # true/false
+
+# Whether to convert all tabs to spaces in comments. If false, tabs in
+# comments are left alone, unless used for indenting.
+cmt_convert_tab_to_spaces       = false    # true/false
+
+# Whether to apply changes to multi-line comments, including cmt_width,
+# keyword substitution and leading chars.
+#
+# Default: true
+cmt_indent_multi                = false    # true/false
+
+# Whether to align doxygen javadoc-style tags ('@param', '@return', etc.)
+# and corresponding fields such that groups of consecutive block tags,
+# parameter names, and descriptions align with one another. Overrides that
+# which is specified by the cmt_sp_after_star_cont. If cmt_width > 0, it may
+# be necessary to enable cmt_indent_multi and set cmt_reflow_mode = 2
+# in order to achieve the desired alignment for line-wrapping.
+cmt_align_doxygen_javadoc_tags  = false    # true/false
+
+# The number of spaces to insert after the star and before doxygen
+# javadoc-style tags (@param, @return, etc). Requires enabling
+# cmt_align_doxygen_javadoc_tags. Overrides that which is specified by the
+# cmt_sp_after_star_cont.
+#
+# Default: 1
+cmt_sp_before_doxygen_javadoc_tags = 1        # unsigned number
+
+# Whether to change trailing, single-line c-comments into cpp-comments.
+cmt_trailing_single_line_c_to_cpp = false    # true/false
+
+# Whether to group c-comments that look like they are in a block.
+cmt_c_group                     = false    # true/false
+
+# Whether to put an empty '/*' on the first line of the combined c-comment.
+cmt_c_nl_start                  = false    # true/false
+
+# Whether to add a newline before the closing '*/' of the combined c-comment.
+cmt_c_nl_end                    = false    # true/false
+
+# Whether to change cpp-comments into c-comments.
+cmt_cpp_to_c                    = false    # true/false
+
+# Whether to group cpp-comments that look like they are in a block. Only
+# meaningful if cmt_cpp_to_c=true.
+cmt_cpp_group                   = false    # true/false
+
+# Whether to put an empty '/*' on the first line of the combined cpp-comment
+# when converting to a c-comment.
+#
+# Requires cmt_cpp_to_c=true and cmt_cpp_group=true.
+cmt_cpp_nl_start                = false    # true/false
+
+# Whether to add a newline before the closing '*/' of the combined cpp-comment
+# when converting to a c-comment.
+#
+# Requires cmt_cpp_to_c=true and cmt_cpp_group=true.
+cmt_cpp_nl_end                  = false    # true/false
+
+# Whether to put a star on subsequent comment lines.
+cmt_star_cont                   = false    # true/false
+
+# The number of spaces to insert at the start of subsequent comment lines.
+cmt_sp_before_star_cont         = 0        # unsigned number
+
+# The number of spaces to insert after the star on subsequent comment lines.
+cmt_sp_after_star_cont          = 3        # unsigned number
+
+# For multi-line comments with a '*' lead, remove leading spaces if the first
+# and last lines of the comment are the same length.
+#
+# Default: true
+cmt_multi_check_last            = false    # true/false
+
+# For multi-line comments with a '*' lead, remove leading spaces if the first
+# and last lines of the comment are the same length AND if the length is
+# bigger as the first_len minimum.
+#
+# Default: 4
+cmt_multi_first_len_minimum     = 4        # unsigned number
+
+# Path to a file that contains text to insert at the beginning of a file if
+# the file doesn't start with a C/C++ comment. If the inserted text contains
+# '$(filename)', that will be replaced with the current file's name.
+cmt_insert_file_header          = ""         # string
+
+# Path to a file that contains text to insert at the end of a file if the
+# file doesn't end with a C/C++ comment. If the inserted text contains
+# '$(filename)', that will be replaced with the current file's name.
+cmt_insert_file_footer          = ""         # string
+
+# Path to a file that contains text to insert before a function definition if
+# the function isn't preceded by a C/C++ comment. If the inserted text
+# contains '$(function)', '$(javaparam)' or '$(fclass)', these will be
+# replaced with, respectively, the name of the function, the javadoc '@param'
+# and '@return' stuff, or the name of the class to which the member function
+# belongs.
+cmt_insert_func_header          = ""         # string
+
+# Path to a file that contains text to insert before a class if the class
+# isn't preceded by a C/C++ comment. If the inserted text contains '$(class)',
+# that will be replaced with the class name.
+cmt_insert_class_header         = ""         # string
+
+# Path to a file that contains text to insert before an Objective-C message
+# specification, if the method isn't preceded by a C/C++ comment. If the
+# inserted text contains '$(message)' or '$(javaparam)', these will be
+# replaced with, respectively, the name of the function, or the javadoc
+# '@param' and '@return' stuff.
+cmt_insert_oc_msg_header        = ""         # string
+
+# Whether a comment should be inserted if a preprocessor is encountered when
+# stepping backwards from a function name.
+#
+# Applies to cmt_insert_oc_msg_header, cmt_insert_func_header and
+# cmt_insert_class_header.
+cmt_insert_before_preproc       = false    # true/false
+
+# Whether a comment should be inserted if a function is declared inline to a
+# class definition.
+#
+# Applies to cmt_insert_func_header.
+#
+# Default: true
+cmt_insert_before_inlines       = false    # true/false
+
+# Whether a comment should be inserted if the function is a class constructor
+# or destructor.
+#
+# Applies to cmt_insert_func_header.
+cmt_insert_before_ctor_dtor     = false    # true/false
+
+#
+# Code modifying options (non-whitespace)
+#
+
+# Add or remove braces on a single-line 'do' statement.
+mod_full_brace_do               = force     # ignore/add/remove/force
+
+# Add or remove braces on a single-line 'for' statement.
+mod_full_brace_for              = force     # ignore/add/remove/force
+
+# (Pawn) Add or remove braces on a single-line function definition.
+mod_full_brace_function         = force     # ignore/add/remove/force
+
+# Add or remove braces on a single-line 'if' statement. Braces will not be
+# removed if the braced statement contains an 'else'.
+mod_full_brace_if               = force     # ignore/add/remove/force
+
+# Whether to enforce that all blocks of an 'if'/'else if'/'else' chain either
+# have, or do not have, braces. If true, braces will be added if any block
+# needs braces, and will only be removed if they can be removed from all
+# blocks.
+#
+# Overrides mod_full_brace_if.
+mod_full_brace_if_chain         = false    # true/false
+
+# Whether to add braces to all blocks of an 'if'/'else if'/'else' chain.
+# If true, mod_full_brace_if_chain will only remove braces from an 'if' that
+# does not have an 'else if' or 'else'.
+mod_full_brace_if_chain_only    = true     # true/false
+
+# Add or remove braces on single-line 'while' statement.
+mod_full_brace_while            = force     # ignore/add/remove/force
+
+# Add or remove braces on single-line 'using ()' statement.
+mod_full_brace_using            = ignore    # ignore/add/remove/force
+
+# Don't remove braces around statements that span N newlines
+mod_full_brace_nl               = 0        # unsigned number
+
+# Whether to prevent removal of braces from 'if'/'for'/'while'/etc. blocks
+# which span multiple lines.
+#
+# Affects:
+#   mod_full_brace_for
+#   mod_full_brace_if
+#   mod_full_brace_if_chain
+#   mod_full_brace_if_chain_only
+#   mod_full_brace_while
+#   mod_full_brace_using
+#
+# Does not affect:
+#   mod_full_brace_do
+#   mod_full_brace_function
+mod_full_brace_nl_block_rem_mlcond = false    # true/false
+
+# Add or remove unnecessary parenthesis on 'return' statement.
+mod_paren_on_return             = remove   # ignore/add/remove/force
+
+# (Pawn) Whether to change optional semicolons to real semicolons.
+mod_pawn_semicolon              = false    # true/false
+
+# Whether to fully parenthesize Boolean expressions in 'while' and 'if'
+# statement, as in 'if (a && b > c)' => 'if (a && (b > c))'.
+mod_full_paren_if_bool          = true     # true/false
+
+# Whether to remove superfluous semicolons.
+mod_remove_extra_semicolon      = true     # true/false
+
+# Whether to remove duplicate include.
+mod_remove_duplicate_include    = true    # true/false
+
+# If a function body exceeds the specified number of newlines and doesn't have
+# a comment after the close brace, a comment will be added.
+mod_add_long_function_closebrace_comment = 0        # unsigned number
+
+# If a namespace body exceeds the specified number of newlines and doesn't
+# have a comment after the close brace, a comment will be added.
+mod_add_long_namespace_closebrace_comment = 0        # unsigned number
+
+# If a class body exceeds the specified number of newlines and doesn't have a
+# comment after the close brace, a comment will be added.
+mod_add_long_class_closebrace_comment = 0        # unsigned number
+
+# If a switch body exceeds the specified number of newlines and doesn't have a
+# comment after the close brace, a comment will be added.
+mod_add_long_switch_closebrace_comment = 0        # unsigned number
+
+# If an #ifdef body exceeds the specified number of newlines and doesn't have
+# a comment after the #endif, a comment will be added.
+mod_add_long_ifdef_endif_comment = 0        # unsigned number
+
+# If an #ifdef or #else body exceeds the specified number of newlines and
+# doesn't have a comment after the #else, a comment will be added.
+mod_add_long_ifdef_else_comment = 0        # unsigned number
+
+# Whether to take care of the case by the mod_sort_xx options.
+mod_sort_case_sensitive         = false    # true/false
+
+# Whether to sort consecutive single-line 'import' statements.
+mod_sort_import                 = false    # true/false
+
+# (C#) Whether to sort consecutive single-line 'using' statements.
+mod_sort_using                  = false    # true/false
+
+# Whether to sort consecutive single-line '#include' statements (C/C++) and
+# '#import' statements (Objective-C). Be aware that this has the potential to
+# break your code if your includes/imports have ordering dependencies.
+mod_sort_include                = true     # true/false
+
+# Whether to prioritize '#include' and '#import' statements that contain
+# filename without extension when sorting is enabled.
+mod_sort_incl_import_prioritize_filename = false    # true/false
+
+# Whether to prioritize '#include' and '#import' statements that does not
+# contain extensions when sorting is enabled.
+mod_sort_incl_import_prioritize_extensionless = false    # true/false
+
+# Whether to prioritize '#include' and '#import' statements that contain
+# angle over quotes when sorting is enabled.
+mod_sort_incl_import_prioritize_angle_over_quotes = true     # true/false
+
+# Whether to ignore file extension in '#include' and '#import' statements
+# for sorting comparison.
+mod_sort_incl_import_ignore_extension = true     # true/false
+
+# Whether to group '#include' and '#import' statements when sorting is enabled.
+mod_sort_incl_import_grouping_enabled = false    # true/false
+
+# Whether to move a 'break' that appears after a fully braced 'case' before
+# the close brace, as in 'case X: { ... } break;' => 'case X: { ... break; }'.
+mod_move_case_break             = true     # true/false
+
+# Add or remove braces around a fully braced case statement. Will only remove
+# braces if there are no variable declarations in the block.
+mod_case_brace                  = remove   # ignore/add/remove/force
+
+# Whether to remove a void 'return;' that appears as the last statement in a
+# function.
+mod_remove_empty_return         = true     # true/false
+
+# Add or remove the comma after the last value of an enumeration.
+mod_enum_last_comma             = remove   # ignore/add/remove/force
+
+# (OC) Whether to organize the properties. If true, properties will be
+# rearranged according to the mod_sort_oc_property_*_weight factors.
+mod_sort_oc_properties          = false    # true/false
+
+# (OC) Weight of a class property modifier.
+mod_sort_oc_property_class_weight = 0        # number
+
+# (OC) Weight of 'atomic' and 'nonatomic'.
+mod_sort_oc_property_thread_safe_weight = 0        # number
+
+# (OC) Weight of 'readwrite' when organizing properties.
+mod_sort_oc_property_readwrite_weight = 0        # number
+
+# (OC) Weight of a reference type specifier ('retain', 'copy', 'assign',
+# 'weak', 'strong') when organizing properties.
+mod_sort_oc_property_reference_weight = 0        # number
+
+# (OC) Weight of getter type ('getter=') when organizing properties.
+mod_sort_oc_property_getter_weight = 0        # number
+
+# (OC) Weight of setter type ('setter=') when organizing properties.
+mod_sort_oc_property_setter_weight = 0        # number
+
+# (OC) Weight of nullability type ('nullable', 'nonnull', 'null_unspecified',
+# 'null_resettable') when organizing properties.
+mod_sort_oc_property_nullability_weight = 0        # number
+
+#
+# Preprocessor options
+#
+
+# Add or remove indentation of preprocessor directives inside #if blocks
+# at brace level 0 (file-level).
+pp_indent                       = ignore    # ignore/add/remove/force
+
+# Whether to indent #if/#else/#endif at the brace level. If false, these are
+# indented from column 1.
+pp_indent_at_level              = false    # true/false
+
+# Specifies the number of columns to indent preprocessors per level
+# at brace level 0 (file-level). If pp_indent_at_level=false, also specifies
+# the number of columns to indent preprocessors per level
+# at brace level > 0 (function-level).
+#
+# Default: 1
+pp_indent_count                 = 0        # unsigned number
+
+# Add or remove space after # based on pp_level of #if blocks.
+pp_space                        = ignore    # ignore/add/remove/force
+
+# Sets the number of spaces per level added with pp_space.
+pp_space_count                  = 0        # unsigned number
+
+# The indent for '#region' and '#endregion' in C# and '#pragma region' in
+# C/C++. Negative values decrease indent down to the first column.
+pp_indent_region                = 0        # number
+
+# Whether to indent the code between #region and #endregion.
+pp_region_indent_code           = false    # true/false
+
+# If pp_indent_at_level=true, sets the indent for #if, #else and #endif when
+# not at file-level. Negative values decrease indent down to the first column.
+#
+# =0: Indent preprocessors using output_tab_size
+# >0: Column at which all preprocessors will be indented
+pp_indent_if                    = 0        # number
+
+# Whether to indent the code between #if, #else and #endif.
+pp_if_indent_code               = false    # true/false
+
+# Whether to indent the body of an #if that encompasses all the code in the file.
+pp_indent_in_guard              = false    # true/false
+
+# Whether to indent '#define' at the brace level. If false, these are
+# indented from column 1.
+pp_define_at_level              = false    # true/false
+
+# Whether to indent '#include' at the brace level.
+pp_include_at_level             = false    # true/false
+
+# Whether to ignore the '#define' body while formatting.
+pp_ignore_define_body           = true     # true/false
+
+# Whether to indent case statements between #if, #else, and #endif.
+# Only applies to the indent of the preprocesser that the case statements
+# directly inside of.
+#
+# Default: true
+pp_indent_case                  = false    # true/false
+
+# Whether to indent whole function definitions between #if, #else, and #endif.
+# Only applies to the indent of the preprocesser that the function definition
+# is directly inside of.
+#
+# Default: true
+pp_indent_func_def              = false    # true/false
+
+# Whether to indent extern C blocks between #if, #else, and #endif.
+# Only applies to the indent of the preprocesser that the extern block is
+# directly inside of.
+#
+# Default: true
+pp_indent_extern                = false    # true/false
+
+# Whether to indent braces directly inside #if, #else, and #endif.
+# Only applies to the indent of the preprocesser that the braces are directly
+# inside of.
+#
+# Default: true
+pp_indent_brace                 = false    # true/false
+
+#
+# Sort includes options
+#
+
+# The regex for include category with priority 0.
+include_category_0              = ""         # string
+
+# The regex for include category with priority 1.
+include_category_1              = ""         # string
+
+# The regex for include category with priority 2.
+include_category_2              = ""         # string
+
+#
+# Use or Do not Use options
+#
+
+# true:  indent_func_call_param will be used (default)
+# false: indent_func_call_param will NOT be used
+#
+# Default: true
+use_indent_func_call_param      = true    # true/false
+
+# The value of the indentation for a continuation line is calculated
+# differently if the statement is:
+# - a declaration: your case with QString fileName ...
+# - an assignment: your case with pSettings = new QSettings( ...
+#
+# At the second case the indentation value might be used twice:
+# - at the assignment
+# - at the function call (if present)
+#
+# To prevent the double use of the indentation value, use this option with the
+# value 'true'.
+#
+# true:  indent_continue will be used only once
+# false: indent_continue will be used every time (default)
+use_indent_continue_only_once   = true     # true/false
+
+# The value might be used twice:
+# - at the assignment
+# - at the opening brace
+#
+# To prevent the double use of the indentation value, use this option with the
+# value 'true'.
+#
+# true:  indentation will be used only once
+# false: indentation will be used every time (default)
+indent_cpp_lambda_only_once     = true     # true/false
+
+# Whether sp_after_angle takes precedence over sp_inside_fparen. This was the
+# historic behavior, but is probably not the desired behavior, so this is off
+# by default.
+use_sp_after_angle_always       = false    # true/false
+
+# Whether to apply special formatting for Qt SIGNAL/SLOT macros. Essentially,
+# this tries to format these so that they match Qt's normalized form (i.e. the
+# result of QMetaObject::normalizedSignature), which can slightly improve the
+# performance of the QObject::connect call, rather than how they would
+# otherwise be formatted.
+#
+# See options_for_QT.cpp for details.
+#
+# Default: true
+use_options_overriding_for_qt_macros = false    # true/false
+
+# If true: the form feed character is removed from the list
+# of whitespace characters.
+# See https://en.cppreference.com/w/cpp/string/byte/isspace
+use_form_feed_no_more_as_whitespace_character = false    # true/false
+
+#
+# Warn levels - 1: error, 2: warning (default), 3: note
+#
+
+# (C#) Warning is given if doing tab-to-\t replacement and we have found one
+# in a C# verbatim string literal.
+#
+# Default: 2
+warn_level_tabs_found_in_verbatim_string_literals = 2        # unsigned number
+
+# Limit the number of loops.
+# Used by uncrustify.cpp to exit from infinite loop.
+# 0: no limit.
+debug_max_number_of_loops       = 0        # number
+
+# Set the number of the line to protocol;
+# Used in the function prot_the_line if the 2. parameter is zero.
+# 0: nothing protocol.
+debug_line_number_to_protocol   = 0        # number
+
+# Set the number of second(s) before terminating formatting the current file,
+# 0: no timeout.
+# only for linux
+debug_timeout                   = 0        # number
+
+# Set the number of characters to be printed if the text is too long,
+# 0: do not truncate.
+debug_truncate                  = 0        # unsigned number
+
+# Meaning of the settings:
+#   Ignore - do not do any changes
+#   Add    - makes sure there is 1 or more space/brace/newline/etc
+#   Force  - makes sure there is exactly 1 space/brace/newline/etc,
+#            behaves like Add in some contexts
+#   Remove - removes space/brace/newline/etc
+#
+#
+# - Token(s) can be treated as specific type(s) with the 'set' option:
+#     `set tokenType tokenString [tokenString...]`
+#
+#     Example:
+#       `set BOOL __AND__ __OR__`
+#
+#     tokenTypes are defined in src/token_enum.h, use them without the
+#     'CT_' prefix: 'CT_BOOL' => 'BOOL'
+#
+#
+# - Token(s) can be treated as type(s) with the 'type' option.
+#     `type tokenString [tokenString...]`
+#
+#     Example:
+#       `type int c_uint_8 Rectangle`
+#
+#     This can also be achieved with `set TYPE int c_uint_8 Rectangle`
+#
+#
+# To embed whitespace in tokenStrings use the '\' escape character, or quote
+# the tokenStrings. These quotes are supported: "'`
+#
+#
+# - Support for the auto detection of languages through the file ending can be
+#   added using the 'file_ext' command.
+#     `file_ext langType langString [langString..]`
+#
+#     Example:
+#       `file_ext CPP .ch .cxx .cpp.in`
+#
+#     langTypes are defined in uncrusify_types.h in the lang_flag_e enum, use
+#     them without the 'LANG_' prefix: 'LANG_CPP' => 'CPP'
+#
+#
+# - Custom macro-based indentation can be set up using 'macro-open',
+#   'macro-else' and 'macro-close'.
+#     `(macro-open | macro-else | macro-close) tokenString`
+#
+#     Example:
+#       `macro-open  BEGIN_TEMPLATE_MESSAGE_MAP`
+#       `macro-open  BEGIN_MESSAGE_MAP`
+#       `macro-close END_MESSAGE_MAP`
+#
+#
+# option(s) with 'not default' value: 232
+#