anchor.diff:  reset_master_vbucket(Bucket) ->
       gen_server:call(server(Bucket), reset_master_vbucket, infinity).
   
  -csv_call(Call, Args) ->
  -    ?views_debug("~nCalling couch_set_view:~p(~p)", [Call, Args]),
  -    try
  -        {__Time, __Result} = timer:tc(couch_set_view, Call, Args),
  -
  -        ?views_debug("~ncouch_set_view:~p call returned ~p in ~bms",
  -                     [Call, __Result, __Time div 1000]),
  -        __Result
  -    catch
  -        __T:__E ->
  -            ?views_debug("~ncouch_set_view:~p(~p) raised ~p:~p",
  -                         [Call, Args, __T, __E]),
  -
  -            __Stack = erlang:get_stacktrace(),
  -            erlang:raise(__T, __E, __Stack)
  -    end.
  +-define(csv_call(Call, Args),
  +        %% hack to not introduce any variables in the caller environment
  +        ((fun () ->
  +                  %% we may want to downgrade it to ?views_debug at some point
  +                  ?views_debug("~nCalling couch_set_view:~p(~p)", [Call, Args]),
  +                  try
  +                      {__Time, __Result} = timer:tc(couch_set_view, Call, Args),
  +
  +                      ?views_debug("~ncouch_set_view:~p(~p) returned ~p in ~bms",
  +                                   [Call, Args, __Result, __Time div 1000]),
  +                      __Result
  +                  catch
  +                      __T:__E ->
  +                          ?views_debug("~ncouch_set_view:~p(~p) raised ~p:~p",
  +                                       [Call, Args, __T, __E]),
  +
  +                          %% rethrowing the exception
  +                          __Stack = erlang:get_stacktrace(),
  +                          erlang:raise(__T, __E, __Stack)
  +                  end
  +          end)())).
  +
   
   compute_index_states(WantedStates, RebalanceStates, ExistingVBuckets) ->
       AllVBs = lists:seq(0, erlang:length(WantedStates)-1),
  
positive.code: 
  apply_index_states(SetName, DDocId, Active, Passive, Cleanup,
                     Replica, ReplicaCleanup, PauseVBuckets, UnpauseVBuckets,
                     State, PastException) ->
  
      try
          case UnpauseVBuckets of
              [] ->
                  ok;
              _ ->
                  ok = csv_call(mark_partitions_indexable,
                                [SetName, DDocId, UnpauseVBuckets])
          end,
  
          %% this should go first because some of the replica vbuckets might
          %% need to be cleaned up from main index
          case Active =/= [] orelse Passive =/= [] orelse Cleanup =/= [] of
              true->
                  ok = csv_call(set_partition_states,
                                [SetName, DDocId, Active, Passive, Cleanup]);
              _ -> ok
          end,
  
          case Replica of
              [] -> ok;
              _ ->
                  ok = csv_call(add_replica_partitions,
                                [SetName, DDocId, Replica])
          end,
          case ReplicaCleanup of
              [] -> ok;
              _ ->
                  ok = csv_call(remove_replica_partitions,
                                [SetName, DDocId, ReplicaCleanup])
          end,
  
          case PauseVBuckets of
              [] -> ok;
              _ ->
                  ok = csv_call(mark_partitions_unindexable,
                                [SetName, DDocId, PauseVBuckets])
          end
  
      catch
          throw:{not_found, deleted} = E ->
              %% The document has been deleted but we still think it's
              %% alive. Eventually we will get a notification from master db
              %% watcher and delete it from a list of design documents.
              Stack = erlang:get_stacktrace(),
              erlang:raise(throw, E, Stack);
          T:E ->
              Stack = erlang:get_stacktrace(),
              Exc = [T, E, Stack],
  
negative.code:             %% previous group for current value of design document can
              %% still be alive; thus using maybe_define_group
              maybe_define_group(DDocId, State),
              change_vbucket_states(State),
              State;
          true ->
              ok
      end,
      {noreply, State};
  
  handle_info(refresh_usable_vbuckets,
  