anchor.diff:      Next = ETS_next(ETSDB, Current),
       get_split_key_inner(DB, Next, RealStart, TargetLoad - 1, Current, ETS_first, ETS_next).
   
  --spec delete_chunk(DB::db(), Interval::intervals:interval(), ChunkSize::pos_integer()) ->
  -    {intervals:interval(), db()}.
  +-spec delete_chunk(DB::db(), Interval::intervals:interval(), ChunkSize::pos_integer() | all)
  +        -> {intervals:interval(), db()}.
   delete_chunk(DB, Interval, ChunkSize) -> delete_chunk_(DB, Interval, ChunkSize).
   
  --spec delete_chunk_(DB::db_t(), Interval::intervals:interval(), ChunkSize::pos_integer()) ->
  -    {intervals:interval(), db_t()}.
  +-spec delete_chunk_(DB::db_t(), Interval::intervals:interval(), ChunkSize::pos_integer() | all)
  +        -> {intervals:interval(), db_t()}.
   delete_chunk_(DB, Interval, ChunkSize) ->
  -    {Next, Chunk} = get_chunk_(DB, Interval, ChunkSize),
  -    DB2 = lists:foldl(fun (Entry, DB1) -> delete_entry(DB1, Entry) end, DB, Chunk),
  +    {Next, Chunk} = get_chunk_(DB, Interval, fun(_) -> true end, fun db_entry:get_key/1, ChunkSize),
  +    DB2 = lists:foldl(fun(Key, DB1) -> delete_entry_at_key(DB1, Key) end, DB, Chunk),
       {Next, DB2}.
  
positive.code: %% pre: Current is in ets table, ets table is not empty
  -spec get_chunk_inner(DB::db_t(), Current::?RT:key() | '$end_of_table',
                        RealStart::?RT:key(), Interval::intervals:interval(),
                        ChunkSize::pos_integer(), Chunk::db_as_list())
          -> {?RT:key() | '$end_of_table' | '$end_of_interval', db_as_list()}.
  get_chunk_inner(_DB, RealStart, RealStart, _Interval, _ChunkSize, Chunk) ->
      %ct:pal("inner: 0: ~p", [RealStart]),
      % we hit the start element, i.e. our whole data set has been traversed
      {'$end_of_interval', Chunk};
  get_chunk_inner(_DB, Current, _RealStart, _Interval, 0, Chunk) ->
      %ct:pal("inner: 1: ~p", [Current]),
      % we hit the chunk size limit
      {Current, Chunk};
  get_chunk_inner({ETSDB, _Subscr} = DB, '$end_of_table', RealStart, Interval, ChunkSize, Chunk) ->
      %ct:pal("inner: 2: ~p", ['$end_of_table']),
      % reached end of table - start at beginning (may be a wrapping interval)
      get_chunk_inner(DB, ets:first(ETSDB), RealStart, Interval, ChunkSize, Chunk);
  get_chunk_inner({ETSDB, _Subscr} = DB, Current, RealStart, Interval, ChunkSize, Chunk) ->
      %ct:pal("inner: 3: ~p", [Current]),
      case intervals:in(Current, Interval) of
          true ->
              Entry = get_entry_(DB, Current),
              Next = ets:next(ETSDB, Current),
              get_chunk_inner(DB, Next, RealStart, Interval, ChunkSize - 1, [Entry | Chunk]);
          _ ->
              {'$end_of_interval', Chunk}
      end.
  
negative.code:                     {intervals:empty(), []};
                  FirstKey ->
                      %ct:pal("first key: ~.0p~n", [FirstKey]),
                      FirstEntry = get_entry_(DB, FirstKey),
                      Chunk0 = case FilterFun(FirstEntry) of
                                   true -> [ValueFun(FirstEntry)];
                                   _    -> []
                               end,
                      {Next, Chunk} =
                          get_chunk_inner(DB, ets:next(ETSDB, FirstKey), FirstKey,
                                          Interval, FilterFun, ValueFun, ChunkSize - 1, Chunk0),
                      case Next of
                          '$end_of_table' ->
                              {intervals:empty(), Chunk};
  