anchor.diff:  
   %% Constants and definitions
   
  --record(state, {bucket, janitor, rebalancer, progress}).
  +-record(state, {bucket, janitor, rebalancer, progress=[], moves}).
   
   %% API
   -export([start_link/1]).
  
positive.code:     {reply, not_running, State};
  handle_call({start_rebalance, KeepNodes, EjectNodes}, _From,
              State = #state{bucket=Bucket, rebalancer=undefined, janitor=Janitor}) ->
      {_NumReplicas, _NumVBuckets, Map, Servers} = ns_bucket:config(Bucket),
      Histograms = histograms(Map, Servers),
      case {lists:sort(Servers), lists:sort(KeepNodes), EjectNodes,
  
negative.code:             Moves
      end.
  
  
  %% Count the number of moves remaining from each node.
  count_moves(Moves) ->
      M = lists:flatmap(fun ({_, Old, New}) -> [Old, New] end, Moves),
      misc:uniqc(lists:sort([N || N <- M, N /= undefined])).
  
  
  do_rebalance(Bucket, KeepNodes, EjectNodes, Map, Tries) ->
      try
          AllNodes = KeepNodes ++ EjectNodes,
          reset_progress(Bucket),
          update_progress(Bucket, AllNodes, 0.0),
          ns_bucket:set_servers(Bucket, AllNodes),
          AliveNodes = ns_node_disco:nodes_actual_proper(),
          RemapNodes = EjectNodes -- AliveNodes, % No active node, promote a replica
          lists:foreach(fun (N) -> ns_cluster:leave(N) end, RemapNodes),
          maybe_stop(),
          EvacuateNodes = EjectNodes -- RemapNodes, % Nodes we can move data off of
          Map1 = promote_replicas(Bucket, Map, RemapNodes),
          ns_bucket:set_map(Bucket, Map1),
          update_progress(Bucket, RemapNodes, 1.0),
          maybe_stop(),
          Histograms1 = histograms(Map1, KeepNodes),
          Moves1 = master_moves(Bucket, EvacuateNodes, Map1, Histograms1),
          starting_moves(Bucket, Moves1),
          Map2 = perform_moves(Bucket, Map1, Moves1),
          update_progress(Bucket, EvacuateNodes, 1.0),
          maybe_stop(),
          Histograms2 = histograms(Map2, KeepNodes),
          Moves2 = balance_nodes(Bucket, Map2, Histograms2, 1),
          starting_moves(Bucket, Moves2),
          Map3 = perform_moves(Bucket, Map2, Moves2),
          update_progress(Bucket, KeepNodes, 0.9),
          maybe_stop(),
          Histograms3 = histograms(Map3, KeepNodes),
          Map4 = new_replicas(Bucket, EjectNodes, Map3, Histograms3),
          ns_bucket:set_map(Bucket, Map4),
          maybe_stop(),
          Histograms4 = histograms(Map4, KeepNodes),
          ChainLength = length(lists:nth(1, Map4)),
  