anchor.diff:              IdxBitsSize = bits_for_number(bits_for_number(DBChunkLen)),
               <<IdxSize:IdxBitsSize/integer-unit:1, Bin/bitstring>>
       end;
  -compress_k_list(KVTree, Bin, SigSize, VSize, AccPos, AccResult, LastPos, Max) ->
  -    <<KeyBin:SigSize/bitstring, _Version:VSize, T/bitstring>> = Bin,
  -    NextPos = AccPos + 1,
  -    case gb_trees:is_defined(KeyBin, KVTree) of
  -        false ->
  -            compress_k_list(KVTree, T, SigSize, VSize, NextPos,
  -                            AccResult, LastPos, Max);
  -        true ->
  -            CurIdx = AccPos - LastPos,
  -            compress_k_list(KVTree, T, SigSize, VSize, NextPos,
  -                            [CurIdx | AccResult], NextPos, erlang:max(CurIdx, Max))
  -    end.
  +compress_idx_list([Pos | Rest], DBChunkLen, AccResult, LastPos, Max) ->
  +    CurIdx = Pos - LastPos,
  +    compress_idx_list(Rest, DBChunkLen, [CurIdx | AccResult], Pos + 1,
  +                      erlang:max(CurIdx, Max)).
   
   %% @doc De-compresses a bitstring with indices from compress_k_list/8 or
   %%      shash_compress_k_list/7 into a list of keys from the original key list.
  
positive.code: %%      and the entry in MyEntries has a newer version than the one in the tree
  %%      and returns them as FBItems. ReqItems contains items in the tree but
  %%      where the version in MyEntries is older than the one in the tree.
  -spec get_part_diff(MyEntries::db_chunk_kv(), MyIOtherKvTree::kv_tree(),
                      AccFBItems::[?RT:key()], AccReqItems::[bitstring()],
                      SigSize::signature_size(), VSize::signature_size())
          -> {FBItems::[?RT:key()], ReqItems::[bitstring()], MyIOtherKvTree::kv_tree()}.
  get_part_diff(MyEntries, MyIOtKvTree, FBItems, ReqItems, SigSize, VSize) ->
      get_part_diff_(MyEntries, MyIOtKvTree, FBItems, ReqItems, SigSize,
                     util:pow(2, VSize)).
  
  %% @doc Helper for get_part_diff/6.
  -spec get_part_diff_(MyEntries::db_chunk_kv(), MyIOtherKvTree::kv_tree(),
                       AccFBItems::[?RT:key()], AccReqItems::[bitstring()],
                       SigSize::signature_size(), VMod::pos_integer())
          -> {FBItems::[?RT:key()], ReqItems::[bitstring()], MyIOtherKvTree::kv_tree()}.
  get_part_diff_([], MyIOtKvTree, FBItems, ReqItems, _SigSize, _VMod) ->
      {FBItems, ReqItems, MyIOtKvTree};
  get_part_diff_([{Key, Version} | Rest], MyIOtKvTree, FBItems, ReqItems, SigSize, VMod) ->
      {KeyBin, VersionShort} = compress_kv_pair(Key, Version, SigSize, VMod),
      case gb_trees:lookup(KeyBin, MyIOtKvTree) of
          none ->
              get_part_diff_(Rest, MyIOtKvTree, FBItems, ReqItems,
                             SigSize, VMod);
          {value, OtherVersionShort} ->
              MyIOtKvTree2 = gb_trees:delete(KeyBin, MyIOtKvTree),
              if VersionShort > OtherVersionShort ->
                     get_part_diff_(Rest, MyIOtKvTree2, [Key | FBItems], ReqItems,
                                    SigSize, VMod);
                 VersionShort =:= OtherVersionShort ->
                     get_part_diff_(Rest, MyIOtKvTree2, FBItems, ReqItems,
                                    SigSize, VMod);
                 true ->
                     get_part_diff_(Rest, MyIOtKvTree2, FBItems, [KeyBin | ReqItems],
                                    SigSize, VMod)
              end
      end.
  
negative.code:     ?TRACE1(_Msg, State),
  
      DBChunkTree =
          decompress_kv_list(OtherDBChunk, [], SigSize, VSize, 0),
      MyDiffKeys = [Key || Key <- decompress_k_list_kv(MyDiffIdx, KVList),
                                  not gb_trees:is_defined(compress_key(Key, SigSize),
                                                          DBChunkTree)],
  
      NewStats2 = shash_bloom_perform_resolve(
                    State, DBChunkTree, SigSize, VSize, DestReconPid, MyDiffKeys,
                    % nothing to do if the chunk is empty and no items to send
                    gb_trees:is_empty(DBChunkTree) andalso MyDiffIdx =:= <<>>),
  
  