anchor.diff:      State3#state{built=false, expired=false}.
   
   destroy_trees(State) ->
  -    State2 = close_trees(State),
  +    State2 = close_trees(State, true),
       {_,Tree0} = hd(State#state.trees), % deliberately using state with live db ref
       _ = hashtree:destroy(Tree0),
       State2.
  
positive.code: has_index_tree(Trees) ->
      orddict:is_key(?INDEX_2I_N, Trees).
  
  close_trees(State=#state{trees=undefined}) ->
      State;
  close_trees(State=#state{trees=Trees}) ->
      Trees2 = [begin
                    NewTree = try
                                  case hashtree:next_rebuild(Tree) of
  
negative.code:                             end,
                    {IdxN, NewTree}
                end || {IdxN, Tree} <- Trees],
      really_close_trees(Trees2, State);
  
  close_trees(#state{trees=Trees} = State, true) ->
      really_close_trees(Trees, State).
  
  really_close_trees(Trees, State) ->
      lists:foreach(fun really_close_tree/1, Trees),
      State#state{trees = undefined}.
  
  really_close_tree({_IdxN, Tree}) -> hashtree:close(Tree).
  
  -spec get_all_locks(build | rehash | upgrade, index(), pid()) -> boolean().
  get_all_locks(Type, Index, Pid) ->
  