anchor.diff:  %% 	What delivery guarantees does sending messages provide?
   receive_committed(committed, S0=#state{num_to_ack= NumToAck}) ->
       case NumToAck of
  -    1 -> 
  -    	lager:info("ClockSI: Finished collecting commit acks. Tx committed succesfully.~n"),
  -    	{next_state, reply_to_client, S0#state{state=committed}, 0};
  -    _ ->
  -        lager:info("ClockSI: Keep collecting commit replies~n"),
  -	{next_state, receive_committed, S0#state{num_to_ack= NumToAck-1}}
  -    end.
  -    
  +        1 -> 
  +            lager:info("ClockSI: Finished collecting commit acks. Tx committed succesfully.~n"),
  +            {next_state, reply_to_client, S0#state{state=committed}, 0};
  +        _ ->
  +            lager:info("ClockSI: Keep collecting commit replies~n"),
  +            {next_state, receive_committed, S0#state{num_to_ack= NumToAck-1}}
  +    end.
  +
   %% when an updated partition does not pass the certification check, the transaction
   %% aborts.
   abort(timeout, SD0=#state{txid=TxId, updated_partitions=UpdatedPartitions}) -> 
  -	clockSI_vnode:abort(UpdatedPartitions, TxId),
  -	NumToAck=lists:lenght(UpdatedPartitions),
  -	{next_state, receive_aborted, SD0#state{state=abort, num_to_ack=NumToAck}, 0};
  +    clockSI_vnode:abort(UpdatedPartitions, TxId),
  +    NumToAck=lists:lenght(UpdatedPartitions),
  +    {next_state, receive_aborted, SD0#state{state=abort, num_to_ack=NumToAck}, 0};
   
   abort(abort, SD0=#state{txid=TxId, updated_partitions=UpdatedPartitions}) -> 
  -	%TODO: Do not send to who issue the abort
  -	clockSI_vnode:abort(UpdatedPartitions, TxId),
  -	NumToAck=length(UpdatedPartitions),
  -	{next_state, receive_aborted, SD0#state{state=abort, num_to_ack=NumToAck}}.
  -	
  +                                                %TODO: Do not send to who issue the abort
  +    clockSI_vnode:abort(UpdatedPartitions, TxId),
  +    NumToAck=length(UpdatedPartitions),
  +    {next_state, receive_aborted, SD0#state{state=abort, num_to_ack=NumToAck}}.
  +
   %%	the fsm waits for acks indicating that each partition has aborted the tx
   %%	and finishes operation.	
   receive_aborted(ack_abort, S0=#state{num_to_ack= NumToAck}) ->
       case NumToAck of 1 -> 
  -   	lager:info("ClockSI-coord-fsm: Finished collecting abort acks. Tx aborted."),
  -    	{next_state, reply_to_client, S0, 0};
  -    _ ->
  -        lager:info("ClockSI-coord-fsm: Keep collecting abort replies~n"),
  -	{next_state, receive_aborted, S0#state{num_to_ack= NumToAck-1}}
  -    end.
  -    
  +            lager:info("ClockSI-coord-fsm: Finished collecting abort acks. Tx aborted."),
  +            {next_state, reply_to_client, S0, 0};
  +        _ ->
  +            lager:info("ClockSI-coord-fsm: Keep collecting abort replies~n"),
  +            {next_state, receive_aborted, S0#state{num_to_ack= NumToAck-1}}
  +    end.
  +
   %% when the transaction has committed or aborted, a reply is sent to the client
   %% that started the transaction.
   reply_to_client(timeout, SD=#state{from=From, txid=TxId, read_set=ReadSet, state=TxState, commit_time=CommitTime}) ->
  -	case TxState of
  -	committed->
  -		From ! {ok, {TxId, ReadSet, CommitTime}};
  -	aborted->
  -		From ! {abort, TxId};
  -	Reason->
  -		From ! {ok, TxId, Reason}
  -	end,
  -	{stop, normal, SD}.
  -
  -	
  -
  -    
  +    case TxState of
  +        committed->
  +            From ! {ok, {TxId, ReadSet, CommitTime}};
  +        aborted->
  +            From ! {abort, TxId};
  +        Reason->
  +            From ! {ok, TxId, Reason}
  +    end,
  +    {stop, normal, SD}.
  +
  +
  +
  +
   %% ====================================================================================
   
   handle_info(_Info, _StateName, StateData) ->
  
positive.code: 
  init([From, ClientClock, Operations]) ->	
  
  	{ok, SnapshotTime}= get_snapshot_time(ClientClock),
  	TransactionId=#tx_id{snapshot_time=clockSI_vnode:now_milisec(SnapshotTime), server_pid=self()},            
      SD = #state{
                  from=From,
                  txid=TransactionId,
                  operations=Operations,
                  updated_partitions=[],
  		prepare_time=0,
                  read_set=[]
  		},
      {ok, prepareOp, SD, 0}.
  
  
  
negative.code: %%		wait for it to finish (synchronous) and go to the prepareOP to execute the next
  %%		operation.
  executeOp(timeout, SD0=#state{
                            currentOp=CurrentOp,
                            txid=TransactionId,
                            updated_partitions=UpdatedPartitions,
                            read_set=ReadSet,
                            currentOpLeader=CurrentOpLeader}) ->
      {OpType, Key, Param}=CurrentOp,
      lager:info("ClockSI-Coord: Execute operation ~w ~n",[CurrentOp]),
      {IndexNode, _} = CurrentOpLeader,
      case OpType of
          read ->
              case clockSI_vnode:read_data_item(IndexNode, TransactionId, Key, Param) of
                  error ->
                      SD1=SD0,
                      {next_state, abort, SD1};
                  ReadResult -> 
                      NewReadSet=lists:append(ReadSet, ReadResult),
                      lager:info("ClockSI-Coord: Read value added to read set: ~p",[CurrentOpLeader]),
                      SD1=SD0#state{read_set=NewReadSet}
              end;
          update ->
              case clockSI_vnode:update_data_item(IndexNode, TransactionId, Key, Param) of
                  ok ->
                      case lists:member(IndexNode, UpdatedPartitions) of
                          false ->
                              lager:info("ClockSI-Coord: Adding Leader node ~w, updt: ~w ~n",[IndexNode, UpdatedPartitions]),
                              NewUpdatedPartitions= lists:append(UpdatedPartitions, [IndexNode]),
                              SD1 = SD0#state{updated_partitions= NewUpdatedPartitions};
                          true->
                              SD1 = SD0
                      end;
                  error ->
                      SD1=SD0,
                      {next_state, abort, SD1}
              end
      end, 
      {next_state, prepareOp, SD1, 0}.
  
  %%	when the tx updates multiple partitions, a two phase commit protocol is started.
  %%	the prepare_2PC state sends a prepare message to all updated partitions and goes
  %%	to the "receive_prepared"state. 
  prepare_2PC(timeout, SD0=#state{txid=TransactionId, updated_partitions=UpdatedPartitions}) ->
      case length(UpdatedPartitions) of
          0->
              SnapshotTime=TransactionId#tx_id.snapshot_time,
              {next_state, committing, SD0#state{state=prepared, commit_time=SnapshotTime}, 0};
          _->
              clockSI_vnode:prepare(UpdatedPartitions, TransactionId),
              NumToAck=length(UpdatedPartitions),
              {next_state, receive_prepared, SD0#state{txid=TransactionId, num_to_ack=NumToAck, state=prepared}}
      end.	
  
  %%	in this state, the fsm waits for prepare_time from each updated partitions in order
  %%	to compute the final tx timestamp (the maximum of the received prepare_time).  
  receive_prepared({prepared, ReceivedPrepareTime}, S0=#state{num_to_ack= NumToAck, prepare_time=PrepareTime}) ->		
      MaxPrepareTime = max(PrepareTime, ReceivedPrepareTime),
      case NumToAck of 1 -> 
              lager:info("ClockSI: Finished collecting prepare replies, start committing... Commit time: ~w~n",[MaxPrepareTime]),
              {next_state, committing, S0#state{prepare_time=MaxPrepareTime, commit_time=MaxPrepareTime, state=committing},0};
          _ ->
              lager:info("ClockSI: Keep collecting prepare replies~n"),
              {next_state, receive_prepared, S0#state{num_to_ack= NumToAck-1, prepare_time=MaxPrepareTime}}
      end;
  
  receive_prepared(abort, S0) ->
      {next_state, abort, S0, 0};   
  
  receive_prepared(timeout, S0) ->
      {next_state, abort, S0 ,0}.
  
  %%	after receiving all prepare_times, send the commit message to all updated partitions,
  %% 	and go to the "receive_committed" state.
  committing(timeout, SD0=#state{txid=TransactionId, updated_partitions=UpdatedPartitions, commit_time=CommitTime}) -> 
      NumToAck=length(UpdatedPartitions),
      case NumToAck of
          0 ->
              lager:info("ClockSI-Coord: No updated partitions. Committing and replying to client."),
              {next_state, reply_to_client, SD0#state{state=committed}, 0};
          _ ->
              clockSI_vnode:commit(UpdatedPartitions, TransactionId, CommitTime),
              {next_state, receive_committed, SD0#state{num_to_ack=NumToAck}}
      end.
  
  %%	the fsm waits for acks indicating that each partition has successfully committed the tx
  %%	and finishes operation.
  %% 	Should we retry sending the committed message if we don't receive a reply from
  