anchor.diff:      } = State,
       stop_all_replications(),
       lists:foreach(
  -        fun(Pid) ->
  +        fun({_Tag, Pid}) ->
               catch unlink(Pid),
               catch exit(Pid, stop)
           end,
  -        [ScanPid | StartPids]),
  +        [{scanner, ScanPid} | StartPids]),
       true = ets:delete(?REP_TO_STATE),
       true = ets:delete(?DOC_TO_REP),
       true = ets:delete(?DB_TO_SEQ),
  
positive.code:     couch_log:error("Database update notifier died. Reason: ~p", [Reason]),
      {stop, {db_update_notifier_died, Reason}, State};
  
  handle_info({'EXIT', From, normal}, #state{rep_start_pids = Pids} = State) ->
      % one of the replication start processes terminated successfully
      {noreply, State#state{rep_start_pids = Pids -- [From]}};
  
  handle_info({'EXIT', From, Reason}, #state{rep_start_pids = Pids} = State) ->
      case lists:member(From, Pids) of
          true ->
              Fmt = "~s : Known replication pid ~w died :: ~w",
              couch_log:error(Fmt, [?MODULE, From, Reason]),
              {noreply, State#state{rep_start_pids = Pids -- [From]}};
          false ->
              Fmt = "~s : Unknown pid ~w died :: ~w",
              couch_log:error(Fmt, [?MODULE, From, Reason]),
  
negative.code:     {stop, {error, {unexpected_call, Msg}}, State}.
  
  handle_cast({resume_scan, DbName}, State) ->
      Pids = State#state.rep_start_pids,
      NewPids = case lists:keyfind(DbName, 1, Pids) of
          {DbName, _Pid} ->
              Entry = case ets:lookup(?DB_TO_SEQ, DbName) of
                  [] ->
                      {DbName, 0, true};
                  [{DbName, EndSeq, _Rescan}] ->
                      {DbName, EndSeq, true}
              end,
              true = ets:insert(?DB_TO_SEQ, Entry),
              Pids;
          false ->
              Since = case ets:lookup(?DB_TO_SEQ, DbName) of
                  [] -> 0;
                  [{DbName, EndSeq, _Rescan}] -> EndSeq
              end,
              true = ets:insert(?DB_TO_SEQ, {DbName, Since, false}),
              ensure_rep_ddoc_exists(DbName),
              Pid = start_changes_reader(DbName, Since),
              couch_log:debug("Scanning ~s from update_seq ~p", [DbName, Since]),
              [{DbName, Pid} | Pids]
      end,
      {noreply, State#state{rep_start_pids = NewPids}};
  
  handle_cast({set_max_retries, MaxRetries}, State) ->
      {noreply, State#state{max_retries = MaxRetries}};
  