anchor.diff:      dump_internal2(DB, EndIndex, CurrentTime, Rest, FunExist, FunNotExist);
   dump_internal(DB, IndexToFetch, EndIndex, CurrentTime, Rest, FunExist, FunNotExist) ->
       NewRest = dump_internal2(DB, IndexToFetch, CurrentTime, Rest, FunExist, FunNotExist),
  -    Count = DB#rrd.count,
  -    dump_internal(DB, (IndexToFetch + 1) rem Count, EndIndex,
  +    dump_internal(DB, (IndexToFetch + 1) rem DB#rrd.count, EndIndex,
                     CurrentTime + DB#rrd.slot_length, NewRest, FunExist, FunNotExist).
   
   dump_internal2(DB, CurrentIndex, CurrentTime, Rest, FunExist, FunNotExist) ->
  -    Data = DB#rrd.data,
       From = CurrentTime,
       To = CurrentTime + DB#rrd.slot_length,
  -    case array:get(CurrentIndex, Data) of
  +    case array:get(CurrentIndex, DB#rrd.data) of
           undefined -> case FunNotExist(DB, From, To) of
                            ignore -> Rest;
                            {keep, X} -> [X | Rest]
  
positive.code: 
  % internal API for the monitor process
  -export([get_slot_start/2, reduce_timeslots/2, add_nonexisting_timeslots/2,
           get_type/1, get_slot_length/1, get_current_time/1, get_value/2,
           add_with/4, timing_with_hist_merge_fun/3]).
  
  % misc
  
negative.code:     CurrentSlot = is_current_slot(Time, CurrentTime, StepSize),
      FutureSlot = is_future_slot(Time, CurrentTime, StepSize),
      {CurrentSlot, FutureSlot}.
  
  %% @doc Goes through the rrd starting at the current slot and returns the value
  %%      that was recorded at the given time (the time must be in the time slot).
  -spec get_value_internal(rrd(), Time::internal_time(), CurrentIdx::non_neg_integer(), EndIdx::non_neg_integer(),
                      CurrentTime::internal_time()) -> data_type() | undefined.
  get_value_internal(DB, Time, EndIndex, EndIndex, CurrentTime) ->
      case is_current_slot(Time, CurrentTime, DB#rrd.slot_length) of
          true -> array:get(EndIndex, DB#rrd.data);
          _    -> undefined
      end;
  get_value_internal(DB, Time, IndexToFetch, EndIndex, CurrentTime) ->
      SlotLength = DB#rrd.slot_length,
      Count = DB#rrd.count,
      case is_current_slot(Time, CurrentTime, SlotLength) of
          true -> array:get(IndexToFetch, DB#rrd.data);
          _    -> get_value_internal(DB, Time, (IndexToFetch + Count - 1) rem Count,
                                     EndIndex, CurrentTime - SlotLength)
      end.
  
  -spec dump_internal(rrd(), CurrentIdx::non_neg_integer(), EndIdx::non_neg_integer(),
                      CurrentTime::internal_time(), Rest::[T],
  