anchor.diff:  
   get_held_locks() ->
       ?MODULE ! {get_table, self(), mnesia_held_locks},
  -    Locks = receive {mnesia_held_locks, Ls} -> Ls  end,
  -    [{Oid, Op, Tid} || {{Oid, Tid}, Op} <- Locks].
  +    Locks = receive {mnesia_held_locks, Ls} -> Ls after 5000 -> [] end,
  +    rewrite_locks(Locks, []).
  +
  +rewrite_locks([{Oid, _, Ls}|Locks], Acc0) ->
  +    Acc = rewrite_locks(Ls, Oid, Acc0),
  +    rewrite_locks(Locks, Acc);
  +rewrite_locks([], Acc) ->
  +    lists:reverse(Acc).
  +
  +rewrite_locks([{Op, Tid}|Ls], Oid, Acc) ->
  +    rewrite_locks(Ls, Oid, [{Oid, Op, Tid}|Acc]);
  +rewrite_locks([], _, Acc) ->
  +    Acc.
   
   get_lock_queue() ->
       ?MODULE ! {get_table, self(), mnesia_lock_queue},
  -    Q = receive {mnesia_lock_queue, Locks} -> Locks  end,
  +    Q = receive {mnesia_lock_queue, Locks} -> Locks after 5000 -> [] end,
       [{Oid, Op, Pid, Tid, WFT} || {queue, Oid, Tid, Op, Pid, WFT} <- Q].
   
   do_stop() ->
  
positive.code: can_lock(Tid, read, {Tab, Key}, AlreadyQ) when Key /= ?ALL ->
      %% The key is bound, no need for the other BIF
      Oid = {Tab, Key},
      ObjLocks = ?ets_match_object(mnesia_held_locks, {{Oid, '_'}, write}),
      TabLocks = ?ets_match_object(mnesia_held_locks, {{{Tab, ?ALL}, '_'}, write}),
      check_lock(Tid, Oid, ObjLocks, TabLocks, yes, AlreadyQ, read);
  
  can_lock(Tid, read, Oid, AlreadyQ) -> % Whole tab
      Tab = element(1, Oid),
      ObjLocks = ?ets_match_object(mnesia_held_locks, {{{Tab, '_'}, '_'}, write}),
      check_lock(Tid, Oid, ObjLocks, [], yes, AlreadyQ, read);
  
  can_lock(Tid, write, {Tab, Key}, AlreadyQ) when Key /= ?ALL ->
      Oid = {Tab, Key},
      ObjLocks = ?ets_match_object(mnesia_held_locks, ?match_oid_held_locks(Oid)),
      TabLocks = ?ets_match_object(mnesia_held_locks, ?match_oid_held_locks({Tab, ?ALL})),
      check_lock(Tid, Oid, ObjLocks, TabLocks, yes, AlreadyQ, write);
  
  can_lock(Tid, write, Oid, AlreadyQ) -> % Whole tab
  
negative.code: release_lock({Tid, Oid, {queued, _}}) ->
      ?ets_match_delete(mnesia_lock_queue, #queue{oid=Oid, tid = Tid, op = '_',
  						pid = '_', lucky = '_'});
  release_lock({This, Oid, Op}) ->
      case ?ets_lookup(mnesia_held_locks, Oid) of
  	[] -> ok;
  	[{Oid, Prev, Locks0}] ->
  	    Locks = [{TOp, Tid} || {TOp, Tid} <- Locks0, Tid =/= This],
  	    if Locks =:= [] ->
  		    ?ets_delete(mnesia_held_locks, Oid);
  	       Op =:= read ->
  		    ?ets_insert(mnesia_held_locks, {Oid, Prev, Locks});
  	       true ->
  		    case lists:any(fun({TOp, _}) -> TOp =:= write end, Locks) of
  			true ->
  			    ?ets_insert(mnesia_held_locks, {Oid, write, Locks});
  			false ->
  			    ?ets_insert(mnesia_held_locks, {Oid, read, Locks})
  		    end
  	    end
      end.
  
  rearrange_queue([{_Tid, {Tab, Key}, _} | Locks]) ->
  