plugins types REFACTOR minor improvements
diff --git a/src/plugins_types.h b/src/plugins_types.h
index 8598c5d..95e1a2e 100644
--- a/src/plugins_types.h
+++ b/src/plugins_types.h
@@ -475,8 +475,10 @@
 #define LYPLG_TYPE_STORE_IMPLEMENT 0x02 /**< If a foreign module is needed to be implemented to successfully instantiate
                                              the value, make the module implemented. */
 #define LYPLG_TYPE_STORE_IS_UTF8   0x04 /**< The value is guaranteed to be a valid UTF-8 string, if applicable for the type. */
-#define LYPLG_TYPE_STORE_ONLY      0x08 /**< The value is stored only. The validation must be done using [validate](@ref lyplg_type_validate_clb) */
-/** @} plugintypestoreopts */
+#define LYPLG_TYPE_STORE_ONLY      0x08 /**< The value is stored only, type-specific validation is skipped (performed before) */
+/**
+ * @} plugintypestoreopts
+ */
 
 /**
  * @brief Callback to store the given @p value according to the given @p type.
@@ -490,7 +492,9 @@
  * @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
+ * No unnecessary validation tasks should be performed by this callback and left for ::lyplg_type_validate_clb instead.
+ *
+ * @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.
@@ -513,15 +517,14 @@
         const struct lysc_node *ctx_node, struct lyd_value *storage, struct lys_glob_unres *unres, struct ly_err_item **err);
 
 /**
- * @brief Callback to validate the stored value in data.
+ * @brief Callback to validate the stored value in the accessible data tree.
  *
- * This callback is optional for types that can only be validated in a data tree. It must be called and succeed
- * 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).
+ * This callback is optional and may not be defined for types that do not require the accessible data tree for
+ * validation (::lyplg_type_store_cb fully stores and validates the value).
  *
- * @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] ctx_node Value data context node for validation.
  * @param[in] tree External data tree (e.g. when validating RPC/Notification) with possibly referenced data.
  * @param[in,out] storage Storage of the value successfully filled by ::lyplg_type_store_clb. May be modified.
  * @param[out] err Optionally provided error information in case of failure. If not provided to the caller, a generic
@@ -619,7 +622,7 @@
     const char *id;                     /**< Plugin identification (mainly for distinguish incompatible versions when
                                              used by external tools) */
     lyplg_type_store_clb store;         /**< store and canonize the value in the type-specific way */
-    lyplg_type_validate_clb validate;   /**< optional, validate the value in the type-specific way in data */
+    lyplg_type_validate_clb validate;   /**< optional, validate the value in the accessible data tree */
     lyplg_type_compare_clb compare;     /**< comparison callback to compare 2 values of the same type */
     lyplg_type_sort_clb sort;           /**< comparison callback for sorting values */
     lyplg_type_print_clb print;         /**< printer callback to get string representing the value */
diff --git a/src/plugins_types/leafref.c b/src/plugins_types/leafref.c
index fee2ef9..5863895 100644
--- a/src/plugins_types/leafref.c
+++ b/src/plugins_types/leafref.c
@@ -41,19 +41,19 @@
         uint32_t options, LY_VALUE_FORMAT format, void *prefix_data, uint32_t hints, const struct lysc_node *ctx_node,
         struct lyd_value *storage, struct lys_glob_unres *unres, struct ly_err_item **err)
 {
-    LY_ERR ret = LY_SUCCESS;
+    LY_ERR rc = LY_SUCCESS;
     struct lysc_type_leafref *type_lr = (struct lysc_type_leafref *)type;
 
     assert(type_lr->realtype);
 
     /* store the value as the real type of the leafref target */
-    ret = type_lr->realtype->plugin->store(ctx, type_lr->realtype, value, value_len, options, format, prefix_data,
+    rc = type_lr->realtype->plugin->store(ctx, type_lr->realtype, value, value_len, options, format, prefix_data,
             hints, ctx_node, storage, unres, err);
-    if (ret == LY_EINCOMPLETE) {
+    if (rc == LY_EINCOMPLETE) {
         /* it is irrelevant whether the target type needs some resolving */
-        ret = LY_SUCCESS;
+        rc = LY_SUCCESS;
     }
-    LY_CHECK_RET(ret);
+    LY_CHECK_RET(rc);
 
     if (type_lr->require_instance) {
         /* needs to be resolved */
@@ -67,7 +67,7 @@
 lyplg_type_validate_leafref(const struct ly_ctx *ctx, const struct lysc_type *type, const struct lyd_node *ctx_node,
         const struct lyd_node *tree, struct lyd_value *storage, struct ly_err_item **err)
 {
-    LY_ERR ret;
+    LY_ERR rc = LY_SUCCESS;
     struct lysc_type_leafref *type_lr = (struct lysc_type_leafref *)type;
     char *errmsg = NULL, *path;
     struct ly_set *targets = NULL;
@@ -80,24 +80,25 @@
         return LY_SUCCESS;
     }
 
-    ret = lyplg_type_resolve_leafref(type_lr, ctx_node, storage, tree, (ly_ctx_get_options(ctx) & LY_CTX_LEAFREF_LINKING) ? &targets : NULL, &errmsg);
-    if (ret != LY_SUCCESS) {
+    rc = lyplg_type_resolve_leafref(type_lr, ctx_node, storage, tree,
+            (ly_ctx_get_options(ctx) & LY_CTX_LEAFREF_LINKING) ? &targets : NULL, &errmsg);
+    if (rc) {
         path = lyd_path(ctx_node, LYD_PATH_STD, NULL, 0);
-        ret = ly_err_new(err, LY_EVALID, LYVE_DATA, path, strdup("instance-required"), "%s", errmsg);
+        rc = ly_err_new(err, LY_EVALID, LYVE_DATA, path, strdup("instance-required"), "%s", errmsg);
         free(errmsg);
         goto cleanup;
     }
 
     if (ly_ctx_get_options(ctx) & LY_CTX_LEAFREF_LINKING) {
         for (i = 0; i < targets->count; ++i) {
-            ret = lyd_link_leafref_node((struct lyd_node_term *)targets->dnodes[i], (struct lyd_node_term *)ctx_node);
-            LY_CHECK_GOTO(ret, cleanup);
+            rc = lyd_link_leafref_node((struct lyd_node_term *)targets->dnodes[i], (struct lyd_node_term *)ctx_node);
+            LY_CHECK_GOTO(rc, cleanup);
         }
     }
 
 cleanup:
     ly_set_free(targets, NULL);
-    return ret;
+    return rc;
 }
 
 LIBYANG_API_DEF LY_ERR
diff --git a/src/plugins_types/union.c b/src/plugins_types/union.c
index b494c95..51cca6c 100644
--- a/src/plugins_types/union.c
+++ b/src/plugins_types/union.c
@@ -493,7 +493,7 @@
 LIBYANG_API_DEF int
 lyplg_type_sort_union(const struct ly_ctx *ctx, const struct lyd_value *val1, const struct lyd_value *val2)
 {
-    int ret;
+    int rc = LY_SUCCESS;
     LY_ARRAY_COUNT_TYPE u;
     struct lysc_type **types;
 
@@ -502,20 +502,19 @@
     }
 
     /* compare according to the order of types */
-    ret = 0;
     types = ((struct lysc_type_union *)val1->realtype)->types;
     LY_ARRAY_FOR(types, u) {
         if (types[u] == val1->subvalue->value.realtype) {
-            ret = 1;
+            rc = 1;
             break;
         } else if (types[u] == val2->subvalue->value.realtype) {
-            ret = -1;
+            rc = -1;
             break;
         }
     }
-    assert(ret != 0);
+    assert(rc != 0);
 
-    return ret;
+    return rc;
 }
 
 /**