anchor.diff:      {Missing, MissingBigDocCount} =
           case length(BigDocIdRevs) of
               V when V > 0 ->
  -                MissingBigIdRevs = find_missing_helper(Target, BigDocIdRevs, XMemSrv),
  +                MissingBigIdRevs = find_missing_helper(Target, BigDocIdRevs, XMemLoc),
                   {lists:flatten([SmallDocIdRevs | MissingBigIdRevs]), length(MissingBigIdRevs)};
               _ ->
                   {SmallDocIdRevs, 0}
  
positive.code:     end.
  
  
  local_process_batch([], _Cp, _Src, _Tgt, #batch{docs = []}, _BatchSize, _BatchItems, _XMemSrv) ->
      {ok, 0};
  local_process_batch([], Cp, #db{} = Source, #httpdb{} = Target,
                      #batch{docs = Docs, size = Size}, BatchSize, BatchItems, XMemSrv) ->
      ?xdcr_trace("worker process flushing a batch docs of total size ~p bytes",
                  [Size]),
      ok = flush_docs_helper(Target, Docs, XMemSrv),
      {ok, DataRepd1} = local_process_batch([], Cp, Source, Target, #batch{}, BatchSize, BatchItems, XMemSrv),
      {ok, DataRepd1 + Size};
  
  local_process_batch([DocInfo | Rest], Cp, #db{} = Source,
                      #httpdb{} = Target, Batch, BatchSize, BatchItems, XMemSrv) ->
      {ok, {_, DocsList, _}} = fetch_doc(
                                        Source, DocInfo, fun local_doc_handler/2,
                                        {Target, [], Cp}),
      {Batch2, DataFlushed} = lists:foldl(
                           fun(Doc, {Batch0, DataFlushed1}) ->
                                   maybe_flush_docs(Target, Batch0, Doc, DataFlushed1, BatchSize, BatchItems, XMemSrv)
                           end,
                           {Batch, 0}, DocsList),
      {ok, DataFlushed2} = local_process_batch(Rest, Cp, Source, Target, Batch2, BatchSize, BatchItems, XMemSrv),
      %% return total data flushed
      {ok, DataFlushed + DataFlushed2}.
  
  
negative.code:     end.
  
  %% return list of Docsinfos of missing keys
  -spec find_missing(list(), #httpdb{}, integer(), term()) -> {list(), integer(), integer()}.
  find_missing(DocInfos, Target, OptRepThreshold, XMemLoc) ->
      Start = now(),
  
      %% depending on doc body size, we separate all keys into two groups:
  