anchor.diff:      lager:info("Nothing to do: ~p", [ST]),
       {take_a_break, ST}.
   
  -do_update_sync_task({done, PeerId}, ST = #sync_task{ chain = Chain }) ->
  -    Chain1 = Chain#{ peers := maps:get(peers, Chain) -- [PeerId] },
  -    ST#sync_task{ chain = Chain1 };
  -do_update_sync_task({error, PeerId}, ST = #sync_task{ chain = Chain }) ->
  -    Chain1 = Chain#{ peers := maps:get(peers, Chain) -- [PeerId] },
  -    ST#sync_task{ chain = Chain1 }.
  +maybe_end_sync_task(State, ST) ->
  +    case ST#sync_task.chain of
  +        #{ peers := [], chain := [Target | _] } ->
  +            lager:info("Removing/ending sync task ~p target was ~p",
  +                       [ST#sync_task.id, Target]),
  +            delete_sync_task(ST, State);
  +        _ ->
  +            set_sync_task(ST, State)
  +    end.
  +
  +do_update_sync_task(State, STId, Update) ->
  +    case get_sync_task(STId, State) of
  +        {ok, ST = #sync_task{ chain = Chain }} ->
  +            Chain1 =
  +                case Update of
  +                    {done, PeerId} ->
  +                        Chain#{ peers := maps:get(peers, Chain) -- [PeerId] };
  +                    {error, PeerId} ->
  +                        Chain#{ peers := maps:get(peers, Chain) -- [PeerId] }
  +                end,
  +            maybe_end_sync_task(State, ST#sync_task{ chain = Chain1 });
  +        {error, not_found} ->
  +            lager:debug("SyncTask ~p not found", [STId]),
  +            State
  +    end.
   
   get_sync_task(STId, #state{ sync_tasks = STs }) ->
       case lists:keyfind(STId, #sync_task.id, STs) of
  
positive.code: update_sync_task(Update, Task) ->
      gen_server:call(?MODULE, {update_sync_task, Update, Task}).
  
  next_work_item(Task, LastResult) ->
      gen_server:call(?MODULE, {next_work_item, Task, LastResult}).
  
  handle_worker(Task, Action) ->
      gen_server:cast(?MODULE, {handle_worker, Task, Action}).
  
negative.code: 
  do_work_on_sync_task(PeerId, Task, LastResult) ->
      %% lager:debug("working on ~p against ~p (Last: ~p)", [Task, ppp(PeerId), LastResult]),
      case next_work_item(Task, PeerId, LastResult) of
          take_a_break ->
              delayed_run_job(PeerId, Task, sync_task_workers,
                              fun() -> do_work_on_sync_task(PeerId, Task) end, 250);
  