diff --git a/src/diff.c b/src/diff.c
index 1ddeee4..5b75499 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -236,7 +236,6 @@
                        char **orig_value, char **key, char **orig_key)
 {
     const struct lysc_node *schema;
-    int dynamic;
     size_t buflen, bufused, first_pos, second_pos;
     struct lyd_diff_userord *userord_item;
 
@@ -307,11 +306,8 @@
     /* value */
     if ((schema->nodetype == LYS_LEAFLIST) && ((*op == LYD_DIFF_OP_REPLACE) || (*op == LYD_DIFF_OP_CREATE))) {
         if (second_pos) {
-            *value = (char *)lyd_value2str((struct lyd_node_term *)userord_item->inst[second_pos - 1], &dynamic);
-            if (!dynamic) {
-                *value = strdup(*value);
-                LY_CHECK_ERR_RET(!*value, LOGMEM(schema->module->ctx), LY_EMEM);
-            }
+            *value = strdup(LYD_CANONICAL(userord_item->inst[second_pos - 1]));
+            LY_CHECK_ERR_RET(!*value, LOGMEM(schema->module->ctx), LY_EMEM);
         } else {
             *value = strdup("");
             LY_CHECK_ERR_RET(!*value, LOGMEM(schema->module->ctx), LY_EMEM);
@@ -321,11 +317,8 @@
     /* orig-value */
     if ((schema->nodetype == LYS_LEAFLIST) && ((*op == LYD_DIFF_OP_REPLACE) || (*op == LYD_DIFF_OP_DELETE))) {
         if (first_pos) {
-            *orig_value = (char *)lyd_value2str((struct lyd_node_term *)userord_item->inst[first_pos - 1], &dynamic);
-            if (!dynamic) {
-                *orig_value = strdup(*orig_value);
-                LY_CHECK_ERR_RET(!*orig_value, LOGMEM(schema->module->ctx), LY_EMEM);
-            }
+            *orig_value = strdup(LYD_CANONICAL(userord_item->inst[first_pos - 1]));
+            LY_CHECK_ERR_RET(!*orig_value, LOGMEM(schema->module->ctx), LY_EMEM);
         } else {
             *orig_value = strdup("");
             LY_CHECK_ERR_RET(!*orig_value, LOGMEM(schema->module->ctx), LY_EMEM);
@@ -405,7 +398,6 @@
                const char **orig_default, char **orig_value)
 {
     const struct lysc_node *schema;
-    int dynamic;
 
     assert(first || second);
 
@@ -475,11 +467,8 @@
     /* orig-value */
     if ((schema->nodetype == LYS_LEAF) && (*op == LYD_DIFF_OP_REPLACE)) {
         /* leaf */
-        *orig_value = (char *)lyd_value2str((struct lyd_node_term *)first, &dynamic);
-        if (!dynamic) {
-            *orig_value = strdup(*orig_value);
-            LY_CHECK_ERR_RET(!*orig_value, LOGMEM(schema->module->ctx), LY_EMEM);
-        }
+        *orig_value = strdup(LYD_CANONICAL(first));
+        LY_CHECK_ERR_RET(!*orig_value, LOGMEM(schema->module->ctx), LY_EMEM);
     }
 
     return LY_SUCCESS;
@@ -748,13 +737,11 @@
     struct lyd_meta *meta = NULL;
     const struct lyd_node *diff_parent;
     const char *str;
-    int dynamic;
 
     for (diff_parent = diff_node; diff_parent; diff_parent = (struct lyd_node *)diff_parent->parent) {
         LY_LIST_FOR(diff_parent->meta, meta) {
             if (!strcmp(meta->name, "operation") && !strcmp(meta->annotation->module->name, "yang")) {
-                str = lyd_meta2str(meta, &dynamic);
-                assert(!dynamic);
+                str = meta->value.canonical;
                 if ((str[0] == 'r') && (diff_parent != diff_node)) {
                     /* we do not care about this operation if it's in our parent */
                     continue;
@@ -871,7 +858,6 @@
     const char *str_val;
     enum lyd_diff_op op;
     struct lyd_meta *meta;
-    int dynamic;
     const struct ly_ctx *ctx = LYD_NODE_CTX(diff_node);
 
     /* read all the valid attributes */
@@ -890,7 +876,7 @@
         /* get "key" or "value" metadata string value */
         meta = lyd_find_meta(diff_node->meta, NULL, diff_node->schema->nodetype == LYS_LIST ? "yang:key" : "yang:value");
         LY_CHECK_ERR_RET(!meta, LOGINT(LYD_NODE_CTX(diff_node)), LY_EINT);
-        str_val = lyd_meta2str(meta, &dynamic);
+        str_val = meta->value.canonical;
 
         /* insert/move the node */
         if (str_val[0]) {
@@ -898,9 +884,6 @@
         } else {
             ret = lyd_diff_insert(first_node, parent_node, match, NULL);
         }
-        if (dynamic) {
-            free((char *)str_val);
-        }
         if (ret) {
             if (op == LYD_DIFF_OP_CREATE) {
                 lyd_free_tree(match);
@@ -969,11 +952,7 @@
         lyd_diff_find_node(*first_node, diff_node, &match);
 
         /* update its value */
-        str_val = lyd_value2str((struct lyd_node_term *)diff_node, &dynamic);
-        ret = lyd_change_term(match, str_val);
-        if (dynamic) {
-            free((char *)str_val);
-        }
+        ret = lyd_change_term(match, LYD_CANONICAL(diff_node));
         if (ret && (ret != LY_EEXIST)) {
             LOGINT_RET(ctx);
         }
@@ -1108,7 +1087,6 @@
 lyd_diff_merge_replace(struct lyd_node *diff_match, enum lyd_diff_op cur_op, const struct lyd_node *src_diff)
 {
     LY_ERR ret;
-    int dynamic;
     const char *str_val, *meta_name;
     struct lyd_meta *meta;
     const struct lys_module *mod;
@@ -1140,26 +1118,16 @@
                 LOGINT_RET(LYD_NODE_CTX(src_diff));
             }
 
-            /* get leaf value */
-            str_val = lyd_value2str((struct lyd_node_term *)src_diff, &dynamic);
-
             /* modify the node value */
-            ret = lyd_change_term(diff_match, str_val);
-            if (dynamic) {
-                free((char *)str_val);
-            }
-            if (ret) {
+            if (lyd_change_term(diff_match, LYD_CANONICAL(src_diff))) {
                 LOGINT_RET(LYD_NODE_CTX(src_diff));
             }
 
             /* compare values whether there is any change at all */
             meta = lyd_find_meta(diff_match->meta, mod, "orig-value");
             LY_CHECK_ERR_RET(!meta, LOGINT(LYD_NODE_CTX(diff_match)), LY_EINT);
-            str_val = lyd_meta2str(meta, &dynamic);
+            str_val = meta->value.canonical;
             ret = lyd_value_compare((struct lyd_node_term *)diff_match, str_val, strlen(str_val), NULL);
-            if (dynamic) {
-                free((char *)str_val);
-            }
             if (!ret) {
                 /* values are the same, remove orig-value meta and set oper to NONE */
                 lyd_free_meta_single(meta);
@@ -1222,9 +1190,6 @@
 {
     struct lyd_node *child;
     const struct lysc_node_leaf *sleaf;
-    const char *str_val;
-    int dynamic;
-    LY_ERR ret;
 
     switch (cur_op) {
     case LYD_DIFF_OP_DELETE:
@@ -1261,20 +1226,10 @@
 
         if (lyd_compare_single(diff_match, src_diff, 0)) {
             /* current value is the previous one (meta) */
-            str_val = lyd_value2str((struct lyd_node_term *)diff_match, &dynamic);
-            ret = lyd_new_meta(diff_match, NULL, "yang:orig-value", str_val, NULL);
-            if (dynamic) {
-                free((char *)str_val);
-            }
-            LY_CHECK_RET(ret);
+            LY_CHECK_RET(lyd_new_meta(diff_match, NULL, "yang:orig-value", LYD_CANONICAL(diff_match), NULL));
 
             /* update the value itself */
-            str_val = lyd_value2str((struct lyd_node_term *)src_diff, &dynamic);
-            ret = lyd_change_term(diff_match, str_val);
-            if (dynamic) {
-                free((char *)str_val);
-            }
-            LY_CHECK_RET(ret);
+            LY_CHECK_RET(lyd_change_term(diff_match, LYD_CANONICAL(src_diff)));
         }
 
         if (diff_match->schema->nodetype & LYD_NODE_TERM) {
@@ -1365,7 +1320,6 @@
     struct lyd_node *child;
     const struct lys_module *mod;
     const char *str;
-    int dynamic;
 
     assert(diff);
 
@@ -1405,8 +1359,7 @@
         /* check whether at least the default flags are different */
         meta = lyd_find_meta(diff->meta, mod, "orig-default");
         assert(meta);
-        str = lyd_meta2str(meta, &dynamic);
-        assert(!dynamic);
+        str = meta->value.canonical;
 
         /* if previous and current dflt flags are the same, this node is redundant */
         if ((!strcmp(str, "true") && (diff->flags & LYD_DEFAULT)) || (!strcmp(str, "false") && !(diff->flags & LYD_DEFAULT))) {
@@ -1557,17 +1510,18 @@
 {
     LY_ERR ret = LY_SUCCESS;
     struct lyd_meta *meta;
-    const char *val1 = NULL, *val2 = NULL;
-    int dyn1 = 0, dyn2 = 0, flags;
+    const char *val1 = NULL;
+    char *val2;
+    int flags;
 
     meta = lyd_find_meta(leaf->meta, mod, "orig-value");
     LY_CHECK_ERR_RET(!meta, LOGINT(LYD_NODE_CTX(leaf)), LY_EINT);
 
     /* orig-value */
-    val1 = lyd_meta2str(meta, &dyn1);
+    val1 = meta->value.canonical;
 
     /* current value */
-    val2 = lyd_value2str((struct lyd_node_term *)leaf, &dyn2);
+    val2 = strdup(LYD_CANONICAL(leaf));
 
     /* switch values, keep default flag */
     flags = leaf->flags;
@@ -1576,12 +1530,7 @@
     LY_CHECK_GOTO(ret = lyd_change_meta(meta, val2), cleanup);
 
 cleanup:
-    if (dyn1) {
-        free((char *)val1);
-    }
-    if (dyn2) {
-        free((char *)val2);
-    }
+    free(val2);
     return ret;
 }
 
@@ -1589,8 +1538,7 @@
 lyd_diff_reverse_default(struct lyd_node *node, const struct lys_module *mod)
 {
     struct lyd_meta *meta;
-    const char *val;
-    int dyn, flag1, flag2;
+    int flag1, flag2;
 
     meta = lyd_find_meta(node->meta, mod, "orig-default");
     if (!meta) {
@@ -1599,9 +1547,7 @@
     }
 
     /* orig-default */
-    val = lyd_meta2str(meta, &dyn);
-    assert(!dyn);
-    if (!strcmp(val, "true")) {
+    if (meta->value.boolean) {
         flag1 = LYD_DEFAULT;
     } else {
         flag1 = 0;
@@ -1623,8 +1569,8 @@
 {
     LY_ERR ret = LY_SUCCESS;
     struct lyd_meta *meta1, *meta2;
-    const char *val1 = NULL, *val2 = NULL;
-    int dyn1 = 0, dyn2 = 0;
+    const char *val1 = NULL;
+    char *val2 = NULL;
 
     meta1 = lyd_find_meta(node->meta, mod, name1);
     LY_CHECK_ERR_RET(!meta1, LOGINT(LYD_NODE_CTX(node)), LY_EINT);
@@ -1633,22 +1579,17 @@
     LY_CHECK_ERR_RET(!meta2, LOGINT(LYD_NODE_CTX(node)), LY_EINT);
 
     /* value1 */
-    val1 = lyd_meta2str(meta1, &dyn1);
+    val1 = meta1->value.canonical;
 
     /* value2 */
-    val2 = lyd_meta2str(meta2, &dyn2);
+    val2 = strdup(meta2->value.canonical);
 
     /* switch values */
     LY_CHECK_GOTO(ret = lyd_change_meta(meta1, val2), cleanup);
     LY_CHECK_GOTO(ret = lyd_change_meta(meta2, val1), cleanup);
 
 cleanup:
-    if (dyn1) {
-        free((char *)val1);
-    }
-    if (dyn2) {
-        free((char *)val2);
-    }
+    free(val2);
     return ret;
 }
 
