anchor.diff:  -spec encode_bucket(tree_id_bin(), integer(), integer()) -> bucket_bin().
   encode_bucket(TreeId, Level, Bucket) ->
       <<$b,TreeId:22/binary,$b,Level:64/integer,Bucket:64/integer>>.
  +
  +-spec decode_bucket(bucket_bin()) -> {tree_id_bin(), integer(), integer()}.
  +decode_bucket(Bin) ->
  +    <<$b,TreeId:22/binary,$b,Level:64/integer,Bucket:64/integer>> = Bin,
  +    {TreeId, Level, Bucket}.
   
   -spec encode_meta(binary()) -> meta_bin().
   encode_meta(Key) ->
  
positive.code:                        %% gb_sets:to_list(Dirty),
                         bitarray_to_list(Dirty)
                 end,
      State2 = maybe_clear_buckets(Segments, State),
      State3 = update_tree(Segments, State2),
      %% State2#state{dirty_segments=gb_sets:new()}
      State3#state{dirty_segments=bitarray_new(NumSegments),
                   next_rebuild=incremental}.
  
  maybe_clear_buckets(?ALL_SEGMENTS, State) ->
      Segments = lists:seq(0, State#state.segments div State#state.width - 1),
      %% Limit the clear to the disk buckets, then dump the whole tree
      State2 = clear_bucket(State#state.mem_levels, State#state.levels, Segments, State),
      State2#state{tree = dict:new()};
  maybe_clear_buckets(_Segments, State) ->
      State.
  
  clear_bucket(MinLevel, Level, _Segments, State) when Level =< MinLevel ->
      State;
  clear_bucket(MinLevel, Level, Segments, State = #state{width = Width}) ->
      State2 = lists:foldl(fun(Segment, State1) ->
                                   del_disk_bucket(Level, Segment, State1)
                           end, State, Segments),
      ParentSegments = lists:usort([Segment div Width || Segment <- Segments]),
      clear_bucket(MinLevel, Level - 1, ParentSegments, State2).
  
  
  -spec update_tree([integer()], hashtree()) -> hashtree().
  update_tree([], State) ->
  
negative.code:     ok = eleveldb:put(Ref, HKey, Bin, []),
      State.
  
  %% del_disk_bucket(Level, Bucket, State = #state{id = Id, ref = Ref}) ->
  %%     HKey = encode_bucket(Id, Level, Bucket),
  %%     ok = eleveldb:delete(Ref, HKey, []),
  %%     State.
  
  -spec encode_id(binary() | non_neg_integer()) -> tree_id_bin().
  encode_id(TreeId) when is_integer(TreeId) ->
  