anchor.diff:  %% @doc This is the only partition being updated by a transaction,
   %%      thus this function performs both the prepare and commit for the
   %%      coordinator that sent the request.
  -handle_command({single_commit, Transaction, WriteSet}, _Sender,
  -    State = #state{partition = _Partition,
  -        committed_tx = CommittedTx,
  -        prepared_tx = PreparedTx,
  +handle_command({single_commit, Transaction, WriteSet}, _Sender, State = #state{
  +    prepared_tx = PreparedTx,
  +    committed_tx = CommittedTx,
       prepared_dict = PreparedDict
  -    }) ->
  +}) ->
  +
       PrepareTime = dc_utilities:now_microsec(),
       {Result, NewPrepare, NewPreparedDict} = prepare(Transaction, WriteSet, CommittedTx, PreparedTx, PrepareTime, PreparedDict),
       NewState = State#state{prepared_dict = NewPreparedDict},
       case Result of
  +        {error, timeout} ->
  +            {reply, {error, timeout}, NewState};
  +
  +        {error, no_updates} ->
  +            {reply, {error, no_tx_record}, NewState};
  +
  +        {error, write_conflict} ->
  +            {reply, abort, State};
  +
           {ok, _} ->
               ResultCommit = commit(Transaction, NewPrepare, WriteSet, CommittedTx, NewState),
               case ResultCommit of
                   {ok, committed, NewPreparedDict2} ->
                       {reply, {committed, NewPrepare}, NewState#state{prepared_dict = NewPreparedDict2}};
  -                {error, materializer_failure} ->
  -                    {reply, {error, materializer_failure}, NewState};
  -                {error, timeout} ->
  -                    {reply, {error, timeout}, NewState};
  +
                   {error, no_updates} ->
  -                    {reply, no_tx_record, NewState}
  -            end;
  -        {error, timeout} ->
  -            {reply, {error, timeout}, NewState};
  -        {error, no_updates} ->
  -            {reply, {error, no_tx_record}, NewState};
  -        {error, write_conflict} ->
  -            {reply, abort, State}
  +                    {reply, no_tx_record, NewState};
  +
  +                {error, Reason} ->
  +                    {reply, {error, Reason}, NewState}
  +            end
       end;
  -
   
   %% TODO: sending empty writeset to clocksi_downstream_generatro
   %% Just a workaround, need to delete downstream_generator_vnode
   %% eventually.
  -handle_command({commit, Transaction, TxCommitTime, Updates}, _Sender,
  -    #state{partition = _Partition,
  -        committed_tx = CommittedTx
  -    } = State) ->
  +handle_command({commit, Transaction, TxCommitTime, Updates}, _Sender, State = #state{
  +    committed_tx = CommittedTx
  +}) ->
  +
       Result = commit(Transaction, TxCommitTime, Updates, CommittedTx, State),
       case Result of
           {ok, committed, NewPreparedDict} ->
               {reply, committed, State#state{prepared_dict = NewPreparedDict}};
  -        {error, materializer_failure} ->
  -            {reply, {error, materializer_failure}, State};
  -        {error, timeout} ->
  -            {reply, {error, timeout}, State};
  +
           {error, no_updates} ->
  -            {reply, no_tx_record, State}
  +            {reply, no_tx_record, State};
  +
  +        {error, Reason} ->
  +            {reply, {error, Reason}, State}
       end;
   
  -handle_command({abort, Transaction, Updates}, _Sender,
  -    #state{partition = _Partition} = State) ->
  +handle_command({abort, Transaction, Updates}, _Sender, State) ->
       TxId = Transaction#transaction.txn_id,
       case Updates of
           [{Key, _Type,  _Update} | _Rest] ->
               LogId = log_utilities:get_logid_from_key(Key),
               Node = log_utilities:get_key_partition(Key),
               LogRecord = #log_operation{tx_id = TxId, op_type = abort, log_payload = #abort_log_payload{}},
  -            Result = logging_vnode:append(Node, LogId, LogRecord),
  -            %% Result = logging_vnode:append(Node, LogId, {TxId, aborted}),
  -            NewPreparedDict = case Result of
  -                  {ok, _} ->
  -                      clean_and_notify(TxId, Updates, State);
  -                  {error, timeout} ->
  -                      clean_and_notify(TxId, Updates, State)
  -                  end,
  +            _Result = logging_vnode:append(Node, LogId, LogRecord),
  +            NewPreparedDict = clean_and_notify(TxId, Updates, State),
               {reply, ack_abort, State#state{prepared_dict = NewPreparedDict}};
  +
           _ ->
               {reply, {error, no_tx_record}, State}
       end;
   
  -handle_command({get_active_txns}, _Sender,
  -    #state{partition = Partition} = State) ->
  +handle_command({get_active_txns}, _Sender, State = #state{partition = Partition}) ->
       {reply, get_active_txns_internal(Partition), State};
   
   handle_command(_Message, _Sender, State) ->
  
positive.code: get_active_txns_key(Key, Partition, TableName) ->
      case ets:info(TableName) of
          undefined ->
              riak_core_vnode_master:sync_command({Partition, node()},
                  {get_active_txns, Key},
                  clocksi_vnode_master,
                  infinity);
          _ ->
              get_active_txns_key_internal(Key, TableName)
      end.
  
  get_active_txns_key_internal(Key, TableName) ->
      ActiveTxs = case ets:lookup(TableName, Key) of
                      [] ->
                          [];
                      [{Key, List}] ->
                          List
                  end,
      {ok, ActiveTxs}.
  
  %% @doc Return active transactions in prepare state with their preparetime for all keys for this partition
  
negative.code: get_active_txns(Partition, TableName) ->
      case ets:info(TableName) of
          undefined ->
              riak_core_vnode_master:sync_command(
                  {Partition, node()},
                  {get_active_txns},
                  clocksi_vnode_master,
                  infinity
              );
  
          _ ->
              get_active_txns_internal(TableName)
      end.
  
  get_active_txns_internal(TableName) ->
      ActiveTxs = case ets:tab2list(TableName) of
          [] ->
              [];
  
          Txns ->
              lists:foldl(fun
                  ({_Key, []}, Acc) ->
                      Acc;
                  ({_Key, List}, Acc) ->
                      List ++ Acc
              end, [], Txns)
      end,
      {ok, ActiveTxs}.
  
  send_min_prepared(Partition) ->
  