anchor.diff:      end.
   
   %% ----- Private functions ------------------------------------
  -mnesia_table_write_access(Fun, Args) when is_atom(Fun), is_list(Args) ->
  +mnesia_atomic(Fun, [_|_] = Args)
  +  when Fun == write; Fun == delete; Fun == delete_object ->
       case apply(mnesia, Fun, Args) of
  -        {atomic,ok} ->
  -            ?TOUCH_SNAP(hd(Args)),
  -            {atomic,ok};
  -        Error ->
  -            Error   
  -    end.
  -
  -mnesia_table_read_access(Fun, Args) when is_atom(Fun), is_list(Args) ->
  -    case apply(mnesia, Fun, Args) of
  -        {atomic,ok} ->
  -            {atomic,ok};
  -        Error ->
  -            Error   
  +        ok -> ?TOUCH_SNAP(hd(Args)),
  +              ok;
  +        Error -> Error
       end.
   
   %% ----- TESTS ------------------------------------------------
  
positive.code: 
  dirty_read(Table, Key) when is_atom(Table) ->
      try
          return_atomic_list(mnesia_table_read_access(dirty_read, [Table, Key]))
      catch
          exit:{aborted, {no_exists,_}} ->    ?ClientErrorNoLogging({"Table does not exist",Table});
          exit:{aborted, {no_exists,_,_}} ->  ?ClientErrorNoLogging({"Table does not exist",Table});
  
negative.code:     NewKey = element(?KeyIdx,New),
      case {mnesia:read(Table, OldKey),(OldKey==NewKey)} of
          {[Old],true} ->    
              mnesia_atomic(write, [Table, New, write]),
              Trigger(Old, New, Table, User, TrOpts),
              {Item,New};
          {[Old],false} ->
              mnesia_atomic(delete, [Table, OldKey, write]),    
              mnesia_atomic(write, [Table, New, write]),
              Trigger(Old, New, Table, User, TrOpts),
              {Item,New};
          {[],_} ->       
              case Lock of
                  none -> mnesia_atomic(write, [Table, New, write]),
                          Trigger(?NoRec, New, Table, User, TrOpts),
                          {Item,New};
                  _ ->    ?ConcurrencyExceptionNoLogging({"Data is deleted by someone else", {Item, Old}})
              end;
          {[Current],true} ->  
              case Lock of
                  none -> mnesia_atomic(write, [Table, New, write]),
                          Trigger(Current, New, Table, User, TrOpts),
                          {Item,New};
                  _ ->    ?ConcurrencyExceptionNoLogging({"Data is modified by someone else", {Item,{Old, Current}}})
              end;
          {[Current],false} ->  
              case Lock of
                  none -> mnesia_atomic(delete, [Table, OldKey, write]),
                          mnesia_atomic(write, [Table, New, write]),
                          Trigger(Current, New, Table, User, TrOpts),
                          {Item,New};
                  _ ->    ?ConcurrencyExceptionNoLogging({"Data is modified by someone else", {Item,{Old, Current}}})
  