anchor.diff:                                  ns_rebalancer:generate_initial_map(BucketConfig)
                           end,
   
  -                    case ns_rebalancer:unbalanced(NewMap, BucketConfig) of
  -                        false ->
  -                            ns_bucket:update_vbucket_map_history(NewMap, Opts);
  -                        true ->
  -                            ok
  -                    end,
  -
  -                    ns_bucket:set_map(Bucket, NewMap),
  -                    ns_bucket:set_map_opts(Bucket, Opts),
  +                    set_initial_map(NewMap, Opts, Bucket, BucketConfig),
  +
                       cleanup(Bucket, Options)
               end;
           _ ->
               cleanup_with_membase_bucket_vbucket_map(Bucket, Options, BucketConfig)
       end.
  +
  +set_initial_map(Map, Opts, Bucket, BucketConfig) ->
  +    case ns_rebalancer:unbalanced(Map, BucketConfig) of
  +        false ->
  +            ns_bucket:update_vbucket_map_history(Map, Opts);
  +        true ->
  +            ok
  +    end,
  +
  +    ns_bucket:set_map(Bucket, Map),
  +    ns_bucket:set_map_opts(Bucket, Opts).
   
   cleanup_with_membase_bucket_vbucket_map(Bucket, Options, BucketConfig) ->
       Servers = proplists:get_value(servers, BucketConfig, []),
  
positive.code:     ?log_info("Bucket ~p not yet ready on ~p", [Bucket, Zombies]),
      {error, wait_for_memcached_failed, Zombies};
  cleanup_with_states(Bucket, Options, BucketConfig, Servers, States,
                      [] = Zombies) ->
      {NewBucketConfig, IgnoredVBuckets} =
          compute_vbucket_map_fixup(Bucket, BucketConfig, States, [] = Zombies),
  
      case NewBucketConfig =:= BucketConfig of
          true ->
              ok;
          false ->
              ?log_info("Janitor is going to change bucket config for bucket ~p",
                        [Bucket]),
              ?log_info("VBucket states:~n~p", [States]),
              ?log_info("Old bucket config:~n~p", [BucketConfig]),
              ok = ns_bucket:set_bucket_config(Bucket, NewBucketConfig)
      end,
  
      %% Find all the unsafe nodes (nodes on which memcached restarted within
      %% the auto-failover timeout) using the vbucket states. If atleast one
  
negative.code:                                         undefined)
      end.
  
  construct_vbucket_states(VBucket, Chain, States) ->
      NodeStates = [{N, S} || {N, V, S} <- States, V == VBucket],
      ChainStates = lists:map(
                      fun (N) ->
  