anchor.diff:                            [?MODULE, Request, From, State]),
       {reply, {unhandled, ?MODULE, Request}, State}.
   
  +handle_cast({update_progress, Progress}, State) ->
  +    {noreply, State#state{progress=Progress}};
   handle_cast(Msg, State) ->
       error_logger:info_msg("~p:handle_cast(~p, ~p)~n",
                             [?MODULE, Msg, State]),
       {noreply, State}.
   
  -handle_info({rebalance_progress, Progress}, State) ->
  -    {noreply, State#state{rebalance_progress = Progress}};
  +handle_info(janitor, State = #state{bucket=Bucket, rebalancer=undefined}) ->
  +    misc:flush(janitor),
  +    {_, _, Map, Servers} = ns_bucket:config(Bucket),
  +    ns_janitor:cleanup(Bucket, Map, Servers),
  +    {noreply, State};
  +handle_info(rebalance_if_new, State = #state{bucket=Bucket,
  +                                             rebalancer=undefined}) ->
  +    case ns_bucket:config(Bucket) of
  +        {_, _, Map, Servers} when Servers == undefined orelse
  +                                Servers == [] ->
  +            error_logger:info_msg("Performing initial rebalance~n"),
  +            {ok, Pid, Ref} =
  +                misc:spawn_link_safe(
  +                  fun () ->
  +                          spawn_link(
  +                            fun() ->
  +                                    do_rebalance(Bucket, [node()], [], Map)
  +                            end)
  +                  end),
  +            {noreply, State#state{rebalancer={Pid, Ref}, progress=[]}};
  +        _ ->
  +            {noreply, State}
  +    end;
   handle_info({Ref, Reason}, State = #state{rebalancer={_Pid, Ref}}) ->
       error_logger:info_msg("~p:handle_info(): rebalance finished with reason ~p~n",
                             [?MODULE, Reason]),
  
positive.code: 
  %% Constants and definitions
  
  -define(INTERVAL, 5000).
  
  -record(state, {bucket, janitor, rebalancer, rebalance_progress}).
  
  %% API
  -export([start_link/1]).
  
  -export([needs_rebalance/1, rebalance_progress/1, start_rebalance/3, stop_rebalance/1]).
  
  %% gen_server callbacks
  -export([init/1, handle_call/3, handle_cast/2,
  
negative.code: 
  %% gen_server callbacks
  init(Bucket) ->
      timer:send_after(1000, rebalance_if_new),
      timer:send_interval(10000, janitor),
      {ok, #state{bucket=Bucket}}.
  
  handle_call(rebalance_progress, _From, State = #state{rebalancer = {_Pid, _Ref},
                                                        progress = Progress}) ->
      {reply, {running, Progress}, State};
  handle_call(rebalance_progress, _From, State) ->
      {reply, not_running, State};
  handle_call({start_rebalance, KeepNodes, EjectNodes}, _From,
              State = #state{bucket=Bucket, rebalancer=undefined}) ->
      {_NumReplicas, _NumVBuckets, Map, Servers} = ns_bucket:config(Bucket),
      Histograms = histograms(Map, Servers),
      case {lists:sort(Servers), lists:sort(KeepNodes), EjectNodes,
            unbalanced(Histograms)} of
          {S, S, [], false} ->
              error_loger:info_msg("ns_orchestrator not rebalancing because already_balanced~n~p~n",
                                  [{Servers, KeepNodes, EjectNodes, Histograms}]),
              {reply, already_balanced, State};
          _ ->
              {ok, Pid, Ref} =
                  misc:spawn_link_safe(
                    fun () ->
                            spawn_link(
                              fun() ->
                                      do_rebalance(Bucket, KeepNodes, EjectNodes, Map)
                              end)
                    end),
              {reply, ok, State#state{rebalancer={Pid, Ref}, progress=[]}}
      end;
  handle_call({start_rebalance, _, _}, _From, State) ->
      error_logger:info_msg("ns_orchestrator not rebalancing because in_progress~n", []),
      {reply, in_progress, State};
  handle_call(stop_rebalance, _From, State = #state{rebalancer={Pid, Ref}}) ->
      Pid ! stop,
  