anchor.diff:      ?TLOGN("aborting transaction ~p", [TransactionID]),
       TransLog = tp_log:get_log(State),
       TransLogUndecided = TransLog#translog.undecided,
  -    IsLogged = gb_trees:is_defined(TransactionID, TransLogUndecided), 
  -    if
  -	IsLogged == true ->
  +    case gb_trees:is_defined(TransactionID, TransLogUndecided) of
  +	true ->
   	    LogEntries = gb_trees:get(TransactionID, TransLogUndecided),
   	    tp_abort_unlock(LogEntries),
   	    NewTransLog = tp_log:get_log(State),
   	    tp_log:remove_from_undecided(State, TransactionID, NewTransLog, TransLogUndecided);
  -	true ->
  +	_Any ->
   	    %%get information about transaction --- might have missed something before
   	    State
       end.
  
positive.code: tp_validate(State, Tid, Item)->
      %?TLOGN("validating item ~p", [Item]),
      %% Check whether the version is still valid
      LocalItemRes = ?DB:read(Item#item.rkey),
     
      if
  	LocalItemRes /= failed -> 
  	    {ok, _, Version} = LocalItemRes,
  	    %?TLOGN("stored locally ~p", [Item#item.key]),
  	    VCheckRes = check_version(Item, Version);
  	true ->
  	    Operation = Item#item.operation,
  	    if 
  		Operation == write ->
  		    VCheckRes = success;
  		true ->
  		    VCheckRes = fail
  	    end    
      end,
      
      %?TLOGN("version check: ~p", [VCheckRes]),
  
      if
  	VCheckRes == success->
  	    case Item#item.operation of
  		read ->
  		    LockRes = ?DB:set_read_lock(Item#item.rkey);
  		write ->
  		    LockRes = ?DB:set_write_lock(Item#item.rkey);
  		_X ->
  		    LockRes = failed
  	    end,
  	    
  	    case LockRes of
  		ok ->
  		    %?TLOGN("lock successful for ~p", [Item#item.rkey]),
  		    NewLogEntry = tp_log:new_logentry(prepared, Tid, Item),
  		    NewState1 = tp_log:add_to_undecided(State, Tid, NewLogEntry),
  		    Decision = prepared;
  		failed ->
  		    %?TLOGN("lock failed for ~p", [Item#item.rkey]), 
                      NewLogEntry = tp_log:new_logentry(local_abort, Tid, Item),
  		    NewState1 = tp_log:add_to_undecided(State, Tid, NewLogEntry),
  		    Decision = abort;
  		_ ->
  		    %% something unexpected resulted
  		    Decision = abort,
  		    NewState1 = State
  	    end;
  	    %% add to log with prepared else with abort TODO??
  	true ->
  	    NewLogEntry = tp_log:new_logentry(local_abort, Tid, Item),
  	    NewState1 = tp_log:add_to_undecided(State, Tid, NewLogEntry),
  	    Decision = abort
      end,
      NewVote = trecords:new_vote(Tid, Item#item.key, Item#item.rkey, Decision, 1),
      
      tsend:send_vote_to_rtms(Item#item.tms, NewVote),
      NewState1.
      
  check_version(TransactionItem, Version)->
      
      case TransactionItem#item.operation of
  	read ->
  	    if
  		TransactionItem#item.version >= Version ->   
  		    success;
  		true ->
  		    fail
  	    end;
  	write ->
  	    if
  		TransactionItem#item.version == (Version + 1) ->
  		    success;
  		true ->
  		    fail
  	    end
      end.
  
  tp_commit(State, TransactionID)->
      %?TLOGN("committing transaction ~p", [TransactionID]),
      TransLog = tp_log:get_log(State),
      TransLogUndecided = TransLog#translog.undecided,
      IsLogged = gb_trees:is_defined(TransactionID, TransLogUndecided), 
      if
  	IsLogged == true ->
  	    LogEntries = gb_trees:get(TransactionID, TransLogUndecided),
  	    tp_commit_store_unlock(LogEntries),
  	    NewTransLog = tp_log:get_log(State),
  	    tp_log:remove_from_undecided(State, TransactionID, NewTransLog, TransLogUndecided);
  	true ->
  	    %%get information about transaction --- might have missed something before
  	    State
      end.
  
negative.code: tp_commit_store_unlock([]) ->
      ok;
  tp_commit_store_unlock([Entry | LogRest])->
      case Entry#logentry.operation of
  	write ->
  	    ?DB:write(Entry#logentry.rkey, Entry#logentry.value, Entry#logentry.version),
  	    %_Stored = ?DB:read(Entry#logentry.rkey),
  	    ?DB:unset_write_lock(Entry#logentry.rkey);
  	_Any ->
  	    ?DB:unset_read_lock(Entry#logentry.rkey)
      end,
      
  