anchor.diff:  open_inner(FH, Table) ->
       case mi_utils:read_value(FH) of
           {ok, {IFT, Value, Props, TS}} ->
  -            write_1(IFT, Value, Props, TS, Table),
  +            write_ets(IFT, Value, Props, TS, Table),
               open_inner(FH, Table);
           eof ->
               ok
  
positive.code:     BytesWritten = mi_utils:write_value(FH, {IFT, Value, Props, TS}),
  
      %% Return a new buffer with a new tree and size...
      write_1(IFT, Value, Props, TS, Buffer#buffer.table),
  
      %% Return the new buffer.
      Buffer#buffer {
          size = (BytesWritten + Buffer#buffer.size)
      }.
  
  write_1(IFT, Value, Props, TS, Table) ->
      %% Update and return the tree...
      Item = {Value, {Props, TS}},
      case ets:lookup(Table, IFT) of
          [] ->
              ets:insert(Table, {IFT, [Item]});
          [{IFT, Items}] ->
              case lists:keytake(Value, 1, Items) of
                  false ->
                      %% Not found, insert the item.
                      ets:insert(Table, {IFT, [Item|Items]});
                  {value, {_, {_, OldTS}}, NewItems} when OldTS < TS ->
                      %% Found, existing item removed, insert the new item.
                      ets:insert(Table, {IFT, [Item|NewItems]});
                  {value, {_, {_, OldTS}}, _NewItems} when OldTS >= TS ->
                      %% Found, but we want to keep the existing item.
                      ok
              end
      end.
  
  %% Return the number of results under this IFT.
  info(IFT, Buffer) ->
      Table = Buffer#buffer.table,
      case ets:lookup(Table, IFT) of
          [{IFT, Values}] ->
              length(Values);
          [] ->
              0
      end.
  
  
  
  %% Return the number of results for IFTs between the StartIFT and
  %% StopIFT, inclusive.
  info(StartIFT, EndIFT, Buffer) ->
      Table = Buffer#buffer.table,
      IFT = mi_utils:ets_next(Table, StartIFT),
      info_1(Table, IFT, EndIFT, 0).
  info_1(_Table, IFT, EndIFT, Count)
  when IFT == '$end_of_table' orelse (EndIFT /= all andalso IFT > EndIFT) ->
      Count;
  info_1(Table, IFT, EndIFT, Count) ->
      [{IFT, Values}] = ets:lookup(Table, IFT),
      NextIFT = ets:next(Table, IFT),
      info_1(Table, NextIFT, EndIFT, Count + length(Values)).
  
  %% Return an iterator function.
  %% Returns Fun/0, which then returns {Term, NewFun} or eof.
  iterator(Buffer) ->
      iterator(undefined, undefined, Buffer).
  
  %% Return an iterator function.
  %% Returns Fun/0, which then returns {Term, NewFun} or eof.
  iterator(StartIFT, EndIFT, Buffer) ->
      Table = Buffer#buffer.table,
      IFT = mi_utils:ets_next(Table, StartIFT),
      Iterator = {Table, IFT, EndIFT},
      fun() -> iterator_1(Iterator) end.
  
  %% Iterate through IFTs...
  iterator_1({_Table, IFT, EndIFT})
  when IFT == '$end_of_table' orelse (EndIFT /= all andalso IFT > EndIFT) ->
      eof;
  iterator_1({Table, IFT, EndIFT}) ->
      [{IFT, Values}] = ets:lookup(Table, IFT),
      SortedValues = lists:sort(Values),
      NextIFT = ets:next(Table, IFT),
      iterator_2(IFT, SortedValues, {Table, NextIFT, EndIFT}).
  
  %% Iterate through values. at a values level...
  iterator_2(IFT, [{Value, {Props, TS}}|Values], Continuation) ->
      Term = {IFT, Value, Props, TS},
      F = fun() -> iterator_2(IFT, Values, Continuation) end,
      {Term, F};
  iterator_2(_IFT, [], Continuation) ->
      iterator_1(Continuation).
  
  test() ->
      %% Write some stuff into the buffer...
      file:delete("/tmp/test_buffer"),
      Buffer = open("/tmp/test_buffer", []),
      Buffer1 = write(3, 11, [], 1, Buffer),
      Buffer2 = write(3, 11, [], 2, Buffer1),
      Buffer3 = write(1, 12, [], 1, Buffer2),
      Buffer4 = write(2, 13, [], 1, Buffer3),
      Buffer5 = write(2, 14, [], 1, Buffer4),
  
      %% Test iterator...
      FA = iterator(Buffer5),
      {{1, 12, [], 1}, FA1} = FA(),
      {{2, 13, [], 1}, FA2} = FA1(),
      {{2, 14, [], 1}, FA3} = FA2(),
      {{3, 11, [], 2}, FA4} = FA3(),
      eof = FA4(),
  
      %% Test partial iterator...
      FB = iterator(2, 2, Buffer5),
      {{2, 13, [], 1}, FB1} = FB(),
      {{2, 14, [], 1}, FB2} = FB1(),
      eof = FB2(),
  
      all_tests_passed.
  
negative.code:     size/1,
      write/5,
      info/2, info/3,
      iterator/1, iterator/3
  ]).
  
  
  -ifdef(TEST).
  -ifdef(EQC).
  -include_lib("eqc/include/eqc.hrl").
  -endif.
  -include_lib("eunit/include/eunit.hrl").
  -endif.
  
  -record(buffer, {
      filename,
  