anchor.diff:  
   -spec update_snapshot(hashtree()) -> {hashtree(), hashtree()}.
   update_snapshot(State=#state{segments=NumSegments}) ->
  -    SnapState = snapshot(State),
  -    State2 = SnapState#state{dirty_segments=bitarray_new(NumSegments)},
  -    {SnapState, State2}.
  +    State2 = flush_buffer(State),
  +    SnapState = snapshot(State2),
  +    State3 = SnapState#state{dirty_segments=bitarray_new(NumSegments)},
  +    {SnapState, State3}.
   
   -spec update_tree(hashtree()) -> hashtree().
   update_tree(State) ->
  -    State2 = snapshot(State),
  -    update_perform(State2).
  +    State2 = flush_buffer(State),
  +    State3 = snapshot(State2),
  +    update_perform(State3).
   
   -spec update_perform(hashtree()) -> hashtree().
   update_perform(State2=#state{dirty_segments=Dirty, segments=NumSegments}) ->
  
positive.code:     HKey = encode(State#state.id, Segment, Key),
      case should_insert(HKey, Opts, State) of
          true ->
              ok = eleveldb:put(State#state.ref, HKey, ObjHash, []),
              %% Dirty = gb_sets:add_element(Segment, State#state.dirty_segments),
              Dirty = bitarray_set(Segment, State#state.dirty_segments),
              State#state{dirty_segments=Dirty};
          false ->
              State
      end.
  
  -spec delete(binary(), hashtree()) -> hashtree().
  delete(Key, State) ->
  
negative.code:                    mem_levels=MemLevels,
                     %% dirty_segments=gb_sets:new(),
                     dirty_segments=bitarray_new(NumSegments),
                     write_buffer=[],
                     write_buffer_count=0,
                     tree=dict:new()},
      State2 = share_segment_store(State, LinkedStore),
      State2.
  