anchor.diff:      check_lock(Tid, Oid, ObjLocks, [], yes, AlreadyQ, write).
   
   %% Check held locks for conflicting locks
  -check_lock(Tid, Oid, [Lock | Locks], TabLocks, X, AlreadyQ, Type) ->
  -    case element(3, Lock) of
  -	Tid ->
  -	    check_lock(Tid, Oid, Locks, TabLocks, X, AlreadyQ, Type);
  -	WaitForTid ->
  -	    Queue = allowed_to_be_queued(WaitForTid,Tid),
  -	    if Queue == true ->
  -		    check_lock(Tid, Oid, Locks, TabLocks, {queue, WaitForTid}, AlreadyQ, Type);
  -	       Tid#tid.pid == WaitForTid#tid.pid ->
  -		    dbg_out("Spurious lock conflict ~w ~w: ~w -> ~w~n",
  -			    [Oid, Lock, Tid, WaitForTid]),
  -		    %% Test..
  -		    {Tab, _Key} = Oid,
  -		    HaveQ = (ets:lookup(mnesia_lock_queue, Oid) /= [])
  -			orelse (ets:lookup(mnesia_lock_queue,{Tab,?ALL}) /= []),
  -		    if
  -			HaveQ ->
  -			    {no, WaitForTid};
  -			true ->
  -			    check_lock(Tid,Oid,Locks,TabLocks,{queue,WaitForTid},AlreadyQ,Type)
  -		    end;
  -		    %%{no, WaitForTid};  Safe solution
  -	       true ->
  -		    {no, WaitForTid}
  -	    end
  +check_lock(Tid, Oid, [{{_,Tid}, _} | Locks], TabLocks, X, AlreadyQ, Type) ->
  +    check_lock(Tid, Oid, Locks, TabLocks, X, AlreadyQ, Type);
  +check_lock(Tid, Oid, [Lock = {{_,WaitForTid}, _} | Locks], TabLocks, _X, AlreadyQ, Type) ->
  +    Queue = allowed_to_be_queued(WaitForTid,Tid),
  +    if Queue == true ->
  +	    check_lock(Tid, Oid, Locks, TabLocks, {queue, WaitForTid}, AlreadyQ, Type);
  +       Tid#tid.pid == WaitForTid#tid.pid ->
  +	    dbg_out("Spurious lock conflict ~w ~w: ~w -> ~w~n",
  +		    [Oid, Lock, Tid, WaitForTid]),
  +	    %% Test..
  +	    {Tab, _Key} = Oid,
  +	    HaveQ = (ets:lookup(mnesia_lock_queue, Oid) /= [])
  +		orelse (ets:lookup(mnesia_lock_queue,{Tab,?ALL}) /= []),
  +	    if
  +		HaveQ ->
  +		    {no, WaitForTid};
  +		true ->
  +		    check_lock(Tid,Oid,Locks,TabLocks,{queue,WaitForTid},AlreadyQ,Type)
  +	    end;
  +       %%{no, WaitForTid};  Safe solution
  +       true ->
  +	    {no, WaitForTid}
       end;
   
   check_lock(_, _, [], [], X, {queue, bad_luck}, _) ->
  
positive.code: init(Parent) ->
      register(?MODULE, self()),
      process_flag(trap_exit, true),
      ?ets_new_table(mnesia_held_locks, [bag, private, named_table]),
      ?ets_new_table(mnesia_tid_locks, [bag, private, named_table]),
      ?ets_new_table(mnesia_sticky_locks, [set, private, named_table]),
      ?ets_new_table(mnesia_lock_queue, [bag, private, named_table, {keypos, 2}]),
  
negative.code: 
  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].
  
  get_lock_queue() ->
      ?MODULE ! {get_table, self(), mnesia_lock_queue},
  