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:                 M1 = M#dnode{num_running = M#dnode.num_running + 1},
                  UNodes = gb_trees:update(Node, M1, Nodes),
                  S1 = S#state{nodes = UNodes, workers = UWorkers},
                  do_schedule_next(S1);
              nojobs ->
                  S
          end;
         true -> S
      end.
  
  -spec do_purge_job(nonempty_string(), #state{}) -> #state{}.
  do_purge_job(JobName, #state{purged = Purged} = S) ->
      handle_call({clean_job, JobName}, none, S),
      ddfs:delete(ddfs_master, disco:oob_name(JobName), internal),
      Key = list_to_binary(JobName),
  