anchor.diff:      end.
   
   
  -local_process_batch([], _Cp, _Src, _Tgt, #batch{docs = []}, _BatchSize, _BatchItems, _XMemSrv) ->
  +local_process_batch([], _Cp, _Src, _Tgt, #batch{docs = []}, _BatchSize, _BatchItems, _XMemLoc) ->
       {ok, 0};
   local_process_batch([], Cp, #db{} = Source, #httpdb{} = Target,
  -                    #batch{docs = Docs, size = Size}, BatchSize, BatchItems, XMemSrv) ->
  +                    #batch{docs = Docs, size = Size}, BatchSize, BatchItems, XMemLoc) ->
       ?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 = flush_docs_helper(Target, Docs, XMemLoc),
  +    {ok, DataRepd1} = local_process_batch([], Cp, Source, Target, #batch{}, BatchSize, BatchItems, XMemLoc),
       {ok, DataRepd1 + Size};
   
   local_process_batch([DocInfo | Rest], Cp, #db{} = Source,
  -                    #httpdb{} = Target, Batch, BatchSize, BatchItems, XMemSrv) ->
  +                    #httpdb{} = Target, Batch, BatchSize, BatchItems, XMemLoc) ->
       {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)
  +                                 maybe_flush_docs(Target, Batch0, Doc, DataFlushed1, BatchSize, BatchItems, XMemLoc)
                            end,
                            {Batch, 0}, DocsList),
  -    {ok, DataFlushed2} = local_process_batch(Rest, Cp, Source, Target, Batch2, BatchSize, BatchItems, XMemSrv),
  +    {ok, DataFlushed2} = local_process_batch(Rest, Cp, Source, Target, Batch2, BatchSize, BatchItems, XMemLoc),
       %% return total data flushed
       {ok, DataFlushed + DataFlushed2}.
   
  
positive.code: 
      %% latency in millisecond
      TotalLatency = round(timer:now_diff(now(), Start) div 1000),
      Latency = case is_pid(XMemSrv) of
                    true ->
                        %% xmem is single doc based
                        try (TotalLatency div BigDocCount) of
                            X -> X
                        catch
                            error:badarith -> 0
                        end;
                    _ ->
                        TotalLatency
                end,
  
  
      RepMode = case is_pid(XMemSrv) of
                    true ->
                        "xmem";
                    _ ->
                        "capi"
                end,
      ?xdcr_trace("[replication mode: ~p] out of all ~p docs, number of small docs (including dels: ~p) is ~p, "
                  "number of big docs is ~p, threshold is ~p bytes, ~n\t"
  
negative.code:     {Missing, MissingBigDocCount} =
          case length(BigDocIdRevs) of
              V when V > 0 ->
                  MissingBigIdRevs = find_missing_helper(Target, BigDocIdRevs, XMemLoc),
                  {lists:flatten([SmallDocIdRevs | MissingBigIdRevs]), length(MissingBigIdRevs)};
              _ ->
                  {SmallDocIdRevs, 0}
  