diff --git a/mod/box/box.h b/mod/box/box.h
index a167590470804ef969d1c821d555584c51c50ad4..fcb031a079fa269178c0d05dd45b46a7819473d4 100644
--- a/mod/box/box.h
+++ b/mod/box/box.h
@@ -155,9 +155,7 @@ extern iproto_callback rw_callback;
 static inline int
 space_n(struct space *sp)
 {
-	if (sp < space || sp >= (space + BOX_SPACE_MAX)) {
-		panic("Invalid space pointer");
-	}
+	assert(sp >= space && sp < (space + BOX_SPACE_MAX));
 	return sp - space;
 }
 
@@ -167,9 +165,7 @@ space_n(struct space *sp)
 static inline int
 key_def_n(struct space *sp, struct key_def *kp)
 {
-	if (kp < sp->key_defs || kp >= (sp->key_defs + sp->key_count)) {
-		panic("Invalid key_def pointer");
-	}
+	assert(kp >= sp->key_defs && kp < (sp->key_defs + sp->key_count));
 	return kp - sp->key_defs;
 }
 
diff --git a/mod/box/box.m b/mod/box/box.m
index cffe64000479cb3bf40f038a35c466bc931cdf8e..ad926279e0bcd5d4811c37e74e8d853abf01ab94 100644
--- a/mod/box/box.m
+++ b/mod/box/box.m
@@ -94,10 +94,10 @@ index_count(struct space *sp)
 {
 	if (!secondary_indexes_enabled) {
 		/* If the secondary indexes are not enabled yet
-		   then we can use only the primary key if any.
-		   So return 1 of there is at least one key which
-		   must be primary and return 0 otherwise. */
-		return sp->key_count >= 1;
+		   then we can use only the primary index. So
+		   return 1 if there is at least one index (which
+		   must be primary) and return 0 otherwise. */
+		return sp->key_count > 0;
 	} else {
 		/* Return the actual number of indexes. */
 		return sp->key_count;