diff --git a/lib/cache/nsec1.c b/lib/cache/nsec1.c
index 9898683e763b3d73fac36b2b70f2f52a265c3baf..2db41556bfa3ae700886599526738e89a53bf372 100644
--- a/lib/cache/nsec1.c
+++ b/lib/cache/nsec1.c
@@ -209,12 +209,12 @@ static const char * find_leq_NSEC1(struct kr_cache *cache, const struct kr_query
 	/* We know it starts before sname, so let's check the other end.
 	 * 1. construct the key for the next name - kwz_hi. */
 	/* it's *full* name ATM */
-	const knot_dname_t *next = eh->data + KR_CACHE_RR_COUNT_SIZE
-				 + 2 /* RDLENGTH from rfc1034 */;
+	const knot_rdata_t *next = (const knot_rdata_t *)
+				(eh->data + KR_CACHE_RR_COUNT_SIZE);
 	if (KR_CACHE_RR_COUNT_SIZE != 2 || get_uint16(eh->data) == 0) {
 		assert(false);
 		return "ERROR";
-		/* TODO: more checks?  Also, `next` computation is kinda messy. */
+		/* TODO: more checks? */
 	}
 	/*
 	WITH_VERBOSE {
@@ -228,13 +228,18 @@ static const char * find_leq_NSEC1(struct kr_cache *cache, const struct kr_query
 		assert(false);
 		return "EINVAL";
 	}
-	ret = kr_dname_lf(chs, next, false);
-#if KNOT_VERSION_HEX >= ((2 << 16) | (7 << 8) | 0)
-	/* We have to lower-case it with libknot >= 2.7; see also RFC 6840 5.1. */
-	if (!ret) {
-		ret = knot_dname_to_lower(next);
+	{
+		/* Lower-case chs; see also RFC 6840 5.1.
+		 * LATER(optim.): we do lots of copying etc. */
+		knot_dname_t lower_buf[KNOT_DNAME_MAXLEN];
+		ret = knot_dname_to_wire(lower_buf, next->data,
+					 MIN(next->len, KNOT_DNAME_MAXLEN));
+		if (ret < 0) { /* _ESPACE */
+			return "range search found record with incorrect contents";
+		}
+		knot_dname_to_lower(lower_buf);
+		ret = kr_dname_lf(chs, lower_buf, false);
 	}
-#endif
 	if (ret) {
 		assert(false);
 		return "ERROR";
@@ -353,13 +358,11 @@ int nsec1_encloser(struct key *k, struct answer *ans,
 	 */
 	knot_dname_t next[KNOT_DNAME_MAXLEN];
 	int ret = knot_dname_to_wire(next, knot_nsec_next(&nsec_rr->rrs), sizeof(next));
-	if (ret >= 0) {
-		ret = knot_dname_to_lower(next);
-	}
 	if (ret < 0) {
 		assert(!ret);
 		return kr_error(ret);
 	}
+	knot_dname_to_lower(next);
 	*clencl_labels = MAX(
 		nsec_matched,
 		knot_dname_matched_labels(qry->sname, next)
diff --git a/modules/hints/hints.c b/modules/hints/hints.c
index de34451a7eef795db3352b030eaf47f14d1d7d56..bea5df0d0a0df44e70ff266bf1bcfeb2da5b2304 100644
--- a/modules/hints/hints.c
+++ b/modules/hints/hints.c
@@ -253,10 +253,7 @@ static int add_pair(struct kr_zonecut *hints, const char *name, const char *addr
 	if (!knot_dname_from_str(key, name, sizeof(key))) {
 		return kr_error(EINVAL);
 	}
-	int ret = knot_dname_to_lower(key);
-	if (ret) {
-		return ret;
-	}
+	knot_dname_to_lower(key);
 	const knot_rdata_t *rdata = addr2rdata(addr);
 	if (!rdata) {
 		return kr_error(EINVAL);