return is->length;
 }
 
+/* Return intset blob size in bytes. */
+size_t intsetBlobLen(intset *is) {
+    return sizeof(intset)+is->length*is->encoding;
+}
+
 #ifdef INTSET_TEST_MAIN
 #include <sys/time.h>
 
 
 int64_t intsetRandom(intset *is);
 uint8_t intsetGet(intset *is, uint32_t pos, int64_t *value);
 uint32_t intsetLen(intset *is);
+size_t intsetBlobLen(intset *is);
 
 #endif // __INTSET_H
 
     return len;
 }
 
-/* Return size in bytes of ziplist. */
-unsigned int ziplistSize(unsigned char *zl) {
+/* Return ziplist blob size in bytes. */
+size_t ziplistBlobLen(unsigned char *zl) {
     return ZIPLIST_BYTES(zl);
 }
 
 
 unsigned char *ziplistDeleteRange(unsigned char *zl, unsigned int index, unsigned int num);
 unsigned int ziplistCompare(unsigned char *p, unsigned char *s, unsigned int slen);
 unsigned int ziplistLen(unsigned char *zl);
-unsigned int ziplistSize(unsigned char *zl);
+size_t ziplistBlobLen(unsigned char *zl);
 
         /* Match or skip the key */
         l = zipmapDecodeLength(p);
         llen = zipmapEncodeLength(NULL,l);
-        if (k == NULL && l == klen && !memcmp(p+llen,key,l)) {
+        if (key != NULL && k == NULL && l == klen && !memcmp(p+llen,key,l)) {
             /* Only return when the user doesn't care
              * for the total length of the zipmap. */
             if (totlen != NULL) {
  * the zipmap on disk (or everywhere is needed) just writing the returned
  * amount of bytes of the C array starting at the zipmap pointer. */
 size_t zipmapBlobLen(unsigned char *zm) {
-    unsigned char *p = zipmapRewind(zm);
-    unsigned char *old = p;
-    while((p = zipmapNext(p,NULL,NULL,NULL,NULL)) != NULL) {
-        old = p;
-    }
-    return (old-zm)+1;
+    unsigned int totlen;
+    zipmapLookupRaw(zm,NULL,0,&totlen);
+    return totlen;
 }
 
+#ifdef ZIPMAP_TEST_MAIN
 void zipmapRepr(unsigned char *p) {
     unsigned int l;
 
     printf("\n");
 }
 
-#ifdef ZIPMAP_TEST_MAIN
 int main(void) {
     unsigned char *zm;