anchor.diff:      
       % lookup up the existing documents, if they exist.
       OldDocLookups = couch_btree:lookup(DocInfoByIdBTree, Ids),
  -    OldDocTrees = lists:map(
  -        fun({ok, #full_doc_info{rev_tree=OldRevTree}}) ->
  -            OldRevTree;
  -        (not_found) ->
  -            []
  +    OldDocInfos = lists:zipwith(
  +        fun(_Id, {ok, FullDocInfo}) ->
  +            FullDocInfo;
  +        (Id, not_found) ->
  +            #full_doc_info{id=Id}
           end,
  -        OldDocLookups),
  +        Ids, OldDocLookups),
       
       {OldCount, OldDelCount} = lists:foldl(
           fun({ok, FullDocInfo}, {OldCountAcc, OldDelCountAcc}) ->
  
positive.code:             #doc_info{deleted=false} ->
                  {OldCountAcc + 1, OldDelCountAcc};
              _ ->
                  {OldCountAcc , OldDelCountAcc + 1}
              end;
          (not_found, Acc) ->
              Acc
  
negative.code: 
  flush_trees(_Db, [], AccFlushedTrees) ->
      {ok, lists:reverse(AccFlushedTrees)};
  flush_trees(#db{fd=Fd}=Db, [InfoUnflushed | RestUnflushed], AccFlushed) ->
          #full_doc_info{rev_tree=Unflushed} = InfoUnflushed,
          Flushed = couch_key_tree:map(
          fun(_Rev, Value) ->
              case Value of
              #doc{attachments=Atts,deleted=IsDeleted}=Doc ->
  