anchor.diff:          end, gb_trees:values(S#state.nodes)),
       disco_proxy:update_nodes(gb_trees:keys(NewNodes)),
       update_nodes(NewNodes),
  -    {noreply, S#state{nodes = NewNodes}};
  -
  -handle_cast(schedule_next, #state{nodes = Nodes, workers = Workers} = S) ->
  -
  +    S#state{nodes = NewNodes}.
  +
  +-spec schedule_next() -> 'ok'.
  +schedule_next() ->
  +    gen_server:cast(?MODULE, schedule_next).
  +
  +-spec do_schedule_next(#state{}) -> #state{}.
  +do_schedule_next(#state{nodes = Nodes, workers = Workers} = S) ->
       {_, AvailableNodes} = lists:unzip(lists:keysort(1, [{Y, N} ||
           #dnode{slots = X, num_running = Y, name = N, blacklisted = false}
                   <- gb_trees:values(Nodes), X > Y])),
  
positive.code:                 purged = gb_trees:empty()}}.
  
  handle_cast({update_config_table, Config}, S) ->
      error_logger:info_report([{"Config table update"}]),
      NewNodes =
          lists:foldl(fun({Host, Slots}, NewNodes) ->
  
negative.code:             false ->
                  gb_trees:insert(Key, now(), Purged)
          end,
      S#state{purged = NPurged}.
  
  -spec do_exit_worker(pid(), _, #state{}) -> #state{}.
  do_exit_worker(Pid, {Type, _} = Res, S) ->
      V = gb_trees:lookup(Pid, S#state.workers),
      if V == none ->
              S;
         true ->
              {_, {Node, Task}} = V,
              UWorkers = gb_trees:delete(Pid, S#state.workers),
              Task#task.from ! {Res, Task, Node},
              schedule_next(),
              update_stats(Node, gb_trees:lookup(Node, S#state.nodes),
                           Type, S#state{workers = UWorkers})
      end.
  