diff --git a/src/knot/ctl/commands.c b/src/knot/ctl/commands.c
index 4fdc958ac2baea221576d0d777625c3b19aa0dfc..57ae2e9321d86afb917d50a11172c483a95ea9d5 100644
--- a/src/knot/ctl/commands.c
+++ b/src/knot/ctl/commands.c
@@ -102,7 +102,7 @@ static int zones_apply(ctl_args_t *args, int (*fcn)(zone_t *, ctl_args_t *))
 
 	while (true) {
 		zone_t *zone;
-		int ret = get_zone(args, &zone);
+		ret = get_zone(args, &zone);
 		if (ret == KNOT_EOK) {
 			ret = fcn(zone, args);
 		}
@@ -343,61 +343,16 @@ static int ctl_server(ctl_args_t *args, ctl_cmd_t cmd)
 	return ret;
 }
 
-static int send_block(conf_io_t *io)
+static int send_block_data(conf_io_t *io, knot_ctl_data_t *data)
 {
 	knot_ctl_t *ctl = (knot_ctl_t *)io->misc;
 
-	// Get possible error message.
-	const char *err = io->error.str;
-	if (err == NULL && io->error.code != KNOT_EOK) {
-		err = knot_strerror(io->error.code);
-	}
-
-	knot_ctl_data_t data = {
-		[KNOT_CTL_IDX_ERROR] = err,
-	};
-
-	if (io->key0 != NULL) {
-		data[KNOT_CTL_IDX_SECTION] = io->key0->name + 1;
-	}
-	if (io->key1 != NULL) {
-		data[KNOT_CTL_IDX_ITEM] = io->key1->name + 1;
-	}
-
-	// Get the item prefix.
-	switch (io->type) {
-	case NEW: data[KNOT_CTL_IDX_FLAGS] = CTL_FLAG_ADD; break;
-	case OLD: data[KNOT_CTL_IDX_FLAGS] = CTL_FLAG_REM; break;
-	default: break;
-	}
-
-	char id[KNOT_DNAME_TXT_MAXLEN + 1] = "\0";
-
-	// Get the textual item id.
-	if (io->id_len > 0 && io->key0 != NULL) {
-		size_t id_len = sizeof(id);
-		int ret = yp_item_to_txt(io->key0->var.g.id, io->id, io->id_len,
-		                         id, &id_len, YP_SNOQUOTE);
-		if (ret != KNOT_EOK) {
-			return ret;
-		}
-		if (io->id_as_data) {
-			data[KNOT_CTL_IDX_DATA] = id;
-		} else {
-			data[KNOT_CTL_IDX_ID] = id;
-		}
-	}
-
-	if (io->data.val == NULL && io->data.bin == NULL) {
-		return knot_ctl_send(ctl, KNOT_CTL_TYPE_DATA, &data);
-	}
-
 	const yp_item_t *item = (io->key1 != NULL) ? io->key1 : io->key0;
 	assert(item != NULL);
 
 	char buff[YP_MAX_TXT_DATA_LEN + 1] = "\0";
 
-	data[KNOT_CTL_IDX_DATA] = buff;
+	(*data)[KNOT_CTL_IDX_DATA] = buff;
 
 	// Format explicit binary data value.
 	if (io->data.bin != NULL) {
@@ -407,7 +362,7 @@ static int send_block(conf_io_t *io)
 		if (ret != KNOT_EOK) {
 			return ret;
 		}
-		return knot_ctl_send(ctl, KNOT_CTL_TYPE_DATA, &data);
+		return knot_ctl_send(ctl, KNOT_CTL_TYPE_DATA, data);
 	// Format all multivalued item data if no specified index.
 	} else if ((item->flags & YP_FMULTI) && io->data.index == 0) {
 		size_t values = conf_val_count(io->data.val);
@@ -423,7 +378,7 @@ static int send_block(conf_io_t *io)
 
 			knot_ctl_type_t type = (i == 0) ? KNOT_CTL_TYPE_DATA :
 			                                  KNOT_CTL_TYPE_EXTRA;
-			ret = knot_ctl_send(ctl, type, &data);
+			ret = knot_ctl_send(ctl, type, data);
 			if (ret != KNOT_EOK) {
 				return ret;
 			}
@@ -440,7 +395,59 @@ static int send_block(conf_io_t *io)
 		if (ret != KNOT_EOK) {
 			return ret;
 		}
+		return knot_ctl_send(ctl, KNOT_CTL_TYPE_DATA, data);
+	}
+}
+
+static int send_block(conf_io_t *io)
+{
+	knot_ctl_t *ctl = (knot_ctl_t *)io->misc;
+
+	// Get possible error message.
+	const char *err = io->error.str;
+	if (err == NULL && io->error.code != KNOT_EOK) {
+		err = knot_strerror(io->error.code);
+	}
+
+	knot_ctl_data_t data = {
+		[KNOT_CTL_IDX_ERROR] = err,
+	};
+
+	if (io->key0 != NULL) {
+		data[KNOT_CTL_IDX_SECTION] = io->key0->name + 1;
+	}
+	if (io->key1 != NULL) {
+		data[KNOT_CTL_IDX_ITEM] = io->key1->name + 1;
+	}
+
+	// Get the item prefix.
+	switch (io->type) {
+	case NEW: data[KNOT_CTL_IDX_FLAGS] = CTL_FLAG_ADD; break;
+	case OLD: data[KNOT_CTL_IDX_FLAGS] = CTL_FLAG_REM; break;
+	default: break;
+	}
+
+	char id[KNOT_DNAME_TXT_MAXLEN + 1] = "\0";
+
+	// Get the textual item id.
+	if (io->id_len > 0 && io->key0 != NULL) {
+		size_t id_len = sizeof(id);
+		int ret = yp_item_to_txt(io->key0->var.g.id, io->id, io->id_len,
+		                         id, &id_len, YP_SNOQUOTE);
+		if (ret != KNOT_EOK) {
+			return ret;
+		}
+		if (io->id_as_data) {
+			data[KNOT_CTL_IDX_DATA] = id;
+		} else {
+			data[KNOT_CTL_IDX_ID] = id;
+		}
+	}
+
+	if (io->data.val == NULL && io->data.bin == NULL) {
 		return knot_ctl_send(ctl, KNOT_CTL_TYPE_DATA, &data);
+	} else {
+		return send_block_data(io, &data);
 	}
 }