anchor.diff:  
   sanify(Bucket, Map, Servers) ->
       {ok, States, _Zombies} = current_states(Servers, Bucket),
  -    sanify(Bucket, States, Map, 0).
  -
  -sanify(_, _, [], _) ->
  -    ok;
  -sanify(Bucket, States, [Chain|Map], VBucket) ->
  +    [sanify_chain(Bucket, States, Chain, VBucket)
  +     || {VBucket, Chain} <- misc:enumerate(Map, 0)].
  +
  +sanify_chain(Bucket, States, Chain, VBucket) ->
       NodeStates = [{N, S} || {N, V, S} <- States, V == VBucket],
       ChainStates = lists:map(fun (N) ->
                                       case lists:keyfind(N, 1, NodeStates) of
  
positive.code: -export([cleanup/3, current_states/2, graphviz/1]).
  
  cleanup(Bucket, Map, Servers) ->
      sanify(Bucket, Map, Servers),
      Replicas = lists:keysort(1, map_to_replicas(Map)),
      ReplicaGroups = lists:ukeymerge(1, misc:keygroup(1, Replicas),
                                      [{N, []} || N <- lists:sort(Servers)]),
  
negative.code:                     error_logger:info_msg(
                        "~p:sanify: Setting master ~p from ~p to active for vbucket ~p~n",
                        [?MODULE, Master, State, VBucket]),
                      ns_memcached:set_vbucket_state(Master, Bucket, VBucket, active),
                      Chain;
                  [Node] ->
                      %% One active node, but it's not the master
                      case lists:position(Node, Chain) of
                          undefined ->
                              %% It's an extra node
                              error_logger:info_msg(
                                "~p:sanify: Master for vbucket ~p is not active, but ~p is, so making that the master.~n",
                                [?MODULE, VBucket, Node]),
                              [Node|lists:duplicate(length(Chain) - 1,
                                                    undefined)];
                          Pos ->
                              [Node|lists:nthtail(1, Pos)]
                      end;
                  Nodes ->
                      error_logger:error_msg(
                        "~p:sanify: Extra active nodes ~p for vbucket ~p. This should never happen!~n",
                        [?MODULE, Nodes, VBucket]),
                      Chain
              end;
          C = [{_, active}|ReplicaStates] ->
              lists:foreach(
  