anchor.diff:  
   % Restore last state
   -export([restore_last_state/1]).
  +
  +% May be useful
  +-export([foldl/3, foldl/4]).
   
   -record(iterator, {
       dbstate,
  
positive.code:     _event ->
        % Iterate
        AccOut = Fun(Event, AccIn),
        do_foldl_full(Fun, AccOut, NextIterator)
    end.
  
  do_foldl_until(Fun, AccIn, Iterator, End) ->
    {Event, NextIterator} = read_event(Iterator),
    case Event of
      eof ->
        % Finish folding -- no more events
        AccIn;
      _event ->
        case packet_timestamp(Event) of
          Large when Large > End ->
            % end of given interval
            AccIn;
          _small ->
            % Iterate
            AccOut = Fun(Event, AccIn),
            do_foldl_until(Fun, AccOut, NextIterator, End)
        end
    end.
  
  
  
negative.code:   end.
  
  % Foldl: low-memory fold over entries
  foldl(Fun, Acc0, Iterator) ->
    do_foldl(Fun, Acc0, Iterator).
  
  % foldl_range: fold over entries in specified time range
  foldl(Fun, Acc0, Iterator, {_Start, _End} = Range) ->
    do_foldl(Fun, Acc0, set_range(Range, Iterator)).
  
  do_foldl(Fun, AccIn, Iterator) ->
    {Event, NextIterator} = read_event(Iterator),
    case Event of
      eof ->
  