anchor.diff:  -record(state, { 
   	  ck    = 0,
   	  age   = 2,
  -	  data  = ets:new(tcache, [named_table]),
  +	  data  = tdtree:new(),
   	  limit = undefined
   	 }).
   
  
positive.code: 
  handle_call(terminate, _From, S0) ->
    {stop, normal, ok, S0}.
  %%------------------------------------------------------------------------------
  %% internal
  %%------------------------------------------------------------------------------
  find_update(X, K, D, W0, _T, S0) ->
    Ko = lists:keysort(1, K),
    Do = lists:keysort(1, D),
    case ets:lookup(S0#state.data, {X,Ko,Do}) of
      [] ->
        Ks = [{Key,Ord} || {{_,Key},Ord} <- Ko],
        Ds = [Key || {_,Key} <- Do],
        io:format(user, "Adding ~p ~p ~p = ~p~n", [X,Ks,Ds,{calc,W0}]),
        true = ets:insert_new(S0#state.data, {{X,Ko,Do}, {calc, W0}}),
        S2 = S0#state{ck = S0#state.ck + 1},
        {reply, {{calc, W0}, S2#state.ck},  S2};
      [{_, {calc, W1} = V}] ->
        case W1 =< W0 of
  	true ->
  	  io:format(user, "Thread ~p is less than or equal to ~p~n", [W1, W0]),
  
negative.code: 	false ->
  	  {reply, {V, S0#state.ck}, S0}
        end;
      V ->
        {reply, {V, S0#state.ck}, S0}
    end.
  
  add_update(X, K, D, W, _T, V1, S0) ->
    KD = lists:keysort(1, tset:restrict_domain(K, D)),
    io:format("Finding ~p ~p~n", [X,KD]),
    case tdtree:lookup({X,KD}, S0#state.data) of
      [] ->
        {reply, hang, S0};
      {calc, W} ->
        case V1 of
  	V1 when is_list(V1) ->
  %%	  io:format(user, "Adding ~p ~p = ~p~n", [X,KD,V1]),
  	  Tr = tdtree:insert({X,KD,{i,V1,[]}}, S0#state.data);
  %%	  io:format(user, "Data = ~p~n", [Tr]);
  	V1 ->
  %%	  io:format(user, "Adding ~p ~p = ~p~n", [X,KD,V1]),
  	  Tr = tdtree:insert({X,KD,V1}, S0#state.data)
  %%	  io:format(user, "Data = ~p~n", [Tr])
        end,
        S1 = S0#state{data = Tr, ck = S0#state.ck + 1},
        {reply, {V1, S1#state.ck}, S1};
      {calc, _} = Thr ->
        io:format("Wrong thread ~p~n", [Thr]),
        {reply, hang, S0};
      Other when is_list(Other) ->
        io:format(user, "Other = ~p, W = ~p~nData1 = ~p~n", [Other, W, S0#state.data]),
        {reply, {Other, S0#state.ck}, S0};
      Other ->
        io:format(user, "Other = ~p, W = ~p~nData1 = ~p~n", [Other, W, S0#state.data]),
        {reply, {Other, S0#state.ck}, S0}
    end.
  
  %%------------------------------------------------------------------------------
  