anchor.diff:  
   %% @hidden
   -spec handle_cast({write|put|delete, term()}, state()) -> {noreply, state()}.
  +
   handle_cast({db_write, Actions}, State) ->
  -  (State#state.backend_mod):write(State#state.backend_ref, Actions),
  +
  +  CategorizeActions = 
  +    fun({put, Key, EdisItem}, [{local_writes, LocalWrites}, {broadcast_writes, AbcastWrites}, LocalState]) -> 
  +          EdisItemLocal = (LocalState#state.backend_mod):get(LocalState#state.backend_ref, Key),
  +          case edis_vclock:descends(EdisItemLocal#edis_item.vclock, EdisItem#edis_item.vclock) orelse EdisItemLocal == not_found of
  +            true -> 
  +              %% The case of when the incoming EdisItem vclock is MORE advanced than the local one
  +              [{local_writes, [{put, Key, EdisItem} | LocalWrites]}, {broadcast_writes, AbcastWrites}, LocalState];
  +            false ->
  +              case edis_vclock:descends(EdisItem#edis_item.vclock, EdisItemLocal#edis_item.vclock) of
  +                true ->
  +                  %% The case of when the incoming EdisItem vclock is LESS advanced than the local one
  +                  [{local_writes, LocalWrites}, {broadcast_writes, [{put, Key, EdisItemLocal} | AbcastWrites]}, LocalState];
  +                false ->
  +                  LocalTS = EdisItemLocal#edis_item.timestamp,
  +                  IncomingTS = EdisItem#edis_item.timestamp,
  +                  DescVClock = edis_vclock:merge([EdisItem#edis_item.vclock, EdisItemLocal#edis_item.vclock]),
  +                  case IncomingTS > LocalTS of
  +                    true ->
  +                      UpdatedVClock = EdisItem#edis_item{vclock = DescVClock},
  +                      [{local_writes, LocalWrites}, {broadcast_writes, [{put, Key, UpdatedVClock} | AbcastWrites]}, LocalState]; 
  +                    false ->
  +                      UpdatedVClock = EdisItemLocal#edis_item{vclock = DescVClock},
  +                      [{local_writes, LocalWrites}, {broadcast_writes, [{put, Key, UpdatedVClock} | AbcastWrites]}, LocalState]
  +                  end
  +              end
  +          end;
  +        ({delete, Key, EdisItem}, [{local_writes, LocalWrites}, {broadcast_writes, AbcastWrites}, LocalState]) -> 
  +          EdisItemLocal = (LocalState#state.backend_mod):get(LocalState#state.backend_ref, Key),
  +          case edis_vclock:descends(EdisItemLocal#edis_item.vclock, EdisItem#edis_item.vclock) orelse EdisItemLocal == not_found of
  +            true -> 
  +              %% The case of when the incoming EdisItem vclock is MORE advanced than the local one
  +              [{local_writes, [{delete, Key} | LocalWrites]}, {broadcast_writes, AbcastWrites}, LocalState];
  +            false ->
  +              case edis_vclock:descends(EdisItem#edis_item.vclock, EdisItemLocal#edis_item.vclock) of
  +                true ->
  +                  %% The case of when the incoming EdisItem vclock is LESS advanced than the local one
  +                  [{local_writes, LocalWrites}, {broadcast_writes, [{delete, Key} | AbcastWrites]}, LocalState]; 
  +                false ->
  +                  LocalTS = EdisItemLocal#edis_item.timestamp,
  +                  IncomingTS = EdisItem#edis_item.timestamp,
  +                  case IncomingTS > LocalTS of
  +                    true -> 
  +                      [{local_writes, LocalWrites}, {broadcast_writes, [{delete, Key} | AbcastWrites]}, LocalState];
  +                    false ->
  +                      [{local_writes, LocalWrites}, {broadcast_writes, [{delete, EdisItemLocal#edis_item.key} | AbcastWrites]}, LocalState]
  +                  end
  +              end
  +          end
  +      end,
  +
  +  NewActions = lists:foldr(CategorizeActions, [{local_writes, []}, {broadcast_writes, []}, State], Actions),
  +  MatchMe = fun([{local, LocalActions},{broadcast, AbcastActions}, MatchState]) -> 
  +    (MatchState#state.backend_mod):write(MatchState#state.backend_ref, LocalActions),
  +    db_write(AbcastActions, MatchState)
  +  end,
  +  MatchMe(NewActions),
     {noreply, State};
   
   handle_cast({db_put, Destination, EdisItem}, State) ->
  -  EdisItemLocal = (State#state.backend_mod):get(State#state.backend_ref, EdisItem),
  -  case edis_vclock:descends(EdisItemLocal#edis_item.vclock, EdisItem#edis_item.vclock) of
  +  EdisItemLocal = (State#state.backend_mod):get(State#state.backend_ref, Destination),
  +  case edis_vclock:descends(EdisItemLocal#edis_item.vclock, EdisItem#edis_item.vclock) orelse EdisItemLocal == not_found of
       true -> 
         %% The case of when the incoming EdisItem vclock is MORE advanced than the local one
  -      db_put(Destination, EdisItem, State)
  +      (State#state.backend_mod):put(
  +                   State#state.backend_ref,
  +                   Destination,
  +                   EdisItem)
     end,
   
     case edis_vclock:descends(EdisItem#edis_item.vclock, EdisItemLocal#edis_item.vclock) of
  
positive.code:   {noreply, State};
  
  handle_cast({db_delete, Destination, EdisItem}, State) ->
    EdisItemLocal = (State#state.backend_mod):get(State#state.backend_ref, EdisItem),
    case edis_vclock:descends(EdisItemLocal#edis_item.vclock, EdisItem#edis_item.vclock) of
      true -> 
        %% The case of when the incoming EdisItem vclock is MORE advanced than the local one
        db_delete(Destination, State)
    end,
  
    case edis_vclock:descends(EdisItem#edis_item.vclock, EdisItemLocal#edis_item.vclock) of
  
negative.code: db_delete(Destination, State) ->
    EdisItem = (State#state.backend_mod):get(State#state.backend_ref, Destination),
    case EdisItem of
      #edis_item{} ->
        NewEdisItem = EdisItem#edis_item{
                                            vclock = edis_vclock:increment(process(State#state.index), EdisItem#edis_item.vclock), 
                                            timestamp = edis_vclock:timestamp()},
        (State#state.backend_mod):delete(State#state.backend_ref, Destination),
        abcast = gen_server:abcast(nodes(), process(State#state.index), {db_delete, Destination, NewEdisItem});
      not_found ->
      %% Assumption: All nodes have agreed once that the item should be deleted.
        not_found;
      {error, Reason} ->
        lager:error("~p~n", [Reason])
  