anchor.diff:  %%% Internal functions
   %%%===================================================================
   
  --spec bucket_dir(binary(), non_neg_integer()) -> string().
  -
  -bucket_dir(Bucket, Partition) ->
  -    DataDir = application:get_env(riak_core, platform_data_dir, "data"),
  -    PartitionDir = DataDir ++ ["/events/", integer_to_list(Partition)],
  -    BucketDir = PartitionDir ++ [$/, binary_to_list(Bucket)],
  +-spec bucket_dir(file:filename_all(), #state{}) -> string().
  +bucket_dir(Bucket, State) when is_binary(Bucket)->
  +    bucket_dir(binary_to_list(Bucket), State);
  +
  +bucket_dir(Bucket, #state{dir = PartitionDir}) when is_list(Bucket) ->
  +    BucketDir = filename:join([PartitionDir, Bucket]),
       file:make_dir(PartitionDir),
       file:make_dir(BucketDir),
       BucketDir.
   
  --spec new_store(non_neg_integer(), binary()) ->
  +-spec new_store(binary(), #state{}) ->
                          estore:estore().
  -new_store(Partition, Bucket) when is_binary(Bucket) ->
  -    BucketDir = bucket_dir(Bucket, Partition),
  +new_store(Bucket, State = #state{partition = Partition})
  +  when is_binary(Bucket) ->
  +    BucketDir = bucket_dir(Bucket, State),
       %% Default bucket points are stored in ms
       PointsPerFile = dalmatiner_opt:ppf(Bucket),
       Resolution = dalmatiner_opt:resolution(Bucket),
  
positive.code:     State1 = State#state{estores = gb_trees:empty()},
      {reply, ok, State1};
  
  handle_call({delete, Bucket}, _From,
               State = #state{dir = Dir}) ->
      {R, State1} = case get_set(Bucket, State) of
                        {ok, {EStore, S1}} ->
                            estore:delete(EStore),
                            file:del_dir([Dir, $/, Bucket]),
                            Estore = gb_trees:delete(Bucket, S1#state.estores),
                            {ok, S1#state{estores = Estore}};
                        _ ->
  
negative.code:         {ok, R} ->
              R;
          {error, not_found} ->
              EStore = new_store(Bucket, State),
              Store1 = gb_trees:insert(Bucket, EStore, Store),
              {EStore, State#state{estores = Store1}}
      end.
  
  bucket_exists(Bucket, State) ->
      BucketDir = bucket_dir(Bucket, State),
      filelib:is_dir(BucketDir).
  
  -spec do_write(binary(), [efile:event()], state()) ->
  