anchor.diff:      % 1 - it has no value and no causal history -> can be deleted
       % 2 - has values, with causal history -> it's a normal write and must be persisted
       % 3 - has values, but no causal history -> it's the final form for this write
  -    {DBOps2, Events1} =
  +    DBOps2  =
       case {map_size(Values1), map_size(Context)} of
           {0, C} when (C == 0) or (State#state.peers == []) -> % case 1
               vmq_swc_dkm:mark_for_gc(DKM, SKey),
  -            {[delete_obj_db_op(SKey, [DbgCategory, strip_save_batch])|DBOps1],
  -             event(deleted, SKey, undefined, OldObj, Events0, State)};
  +            event(deleted, SKey, undefined, OldObj, State),
  +            [delete_obj_db_op(SKey, [DbgCategory, strip_save_batch])|DBOps1];
           {0, _} -> % case 0
               vmq_swc_dkm:mark_for_gc(DKM, SKey),
  -            {[update_obj_db_op(SKey, StrippedObj1, [DbgCategory, strip_save_batch])|DBOps1],
  -             event(deleted, SKey, undefined, OldObj, Events0, State)};
  +            event(deleted, SKey, undefined, OldObj, State),
  +            [update_obj_db_op(SKey, StrippedObj1, [DbgCategory, strip_save_batch])|DBOps1];
           _ -> % case 2 & 3
  -            {[update_obj_db_op(SKey, StrippedObj1, [DbgCategory, strip_save_batch])|DBOps1],
  -             event(updated, SKey, StrippedObj1, OldObj, Events0, State)}
  +            event(updated, SKey, StrippedObj1, OldObj, State),
  +            [update_obj_db_op(SKey, StrippedObj1, [DbgCategory, strip_save_batch])|DBOps1]
       end,
  -    strip_save_batch(Rest, DBOps2, Events1, State, DbgCategory).
  -
  -event(Type, SKey, NewObj, OldObj, EventsAcc, #state{subscriptions=Subscriptions}) ->
  +    strip_save_batch(Rest, DBOps2, State, DbgCategory).
  +
  +event(Type, SKey, NewObj, OldObj, #state{subscriptions=Subscriptions}) ->
       {FullPrefix, Key} = sext:decode(SKey),
       OldValues = swc_kv:values(OldObj),
       SubsForPrefix = maps:get(FullPrefix, Subscriptions, []),
  -    lists:foldl(
  +    lists:foreach(
         fun
  -          ({Pid, ConvertFun}, Acc) when Type == deleted ->
  -              [{Pid, ConvertFun({deleted, FullPrefix, Key, OldValues})}|Acc];
  -          ({Pid, ConvertFun}, Acc) when Type == updated ->
  -              [{Pid, ConvertFun({updated, FullPrefix, Key, OldValues, swc_kv:values(NewObj)})}|Acc]
  -      end, EventsAcc, SubsForPrefix).
  -
  -trigger_events([{Pid, Event}|Rest]) ->
  -    Pid ! Event,
  -    trigger_events(Rest);
  -trigger_events([]) -> ok.
  -
  -process_write_op({Key, Value, MaybeContext}, {AccReplicate0, AccDBOps0, AccEvents0, #state{config=Config, id=Id, nodeclock=NodeClock0} = State0}) ->
  +          ({Pid, ConvertFun}) when Type == deleted ->
  +              Pid ! ConvertFun({deleted, FullPrefix, Key, OldValues});
  +          ({Pid, ConvertFun}) when Type == updated ->
  +              Pid ! ConvertFun({updated, FullPrefix, Key, OldValues, swc_kv:values(NewObj)})
  +      end, SubsForPrefix).
  +
  +process_write_op({Key, Value, MaybeContext}, {AccReplicate0, AccDBOps0, #state{config=Config, id=Id, nodeclock=NodeClock0} = State0}) ->
       % sext encode key
       SKey = sext:encode(Key),
       % get and fill the causal history of the local key
  
positive.code:                                           peers=Peers,
                                            id=Id,
                                            broadcast_enabled=IsBroadcastEnabled} = State0) ->
      {{ReplicateObjects, DbOps, Events, #state{nodeclock=NodeClock} = State1}, Replies} =
      lists:foldl(fun({From, {write, WriteOps}}, {Acc0, RAcc}) ->
                          Acc1 =
                          lists:foldl(fun(WriteOp, AccAcc0) ->
                                              process_write_op(WriteOp, AccAcc0)
                                      end, Acc0, WriteOps),
                          {Acc1, [From|RAcc]}
                  end, {{[], [], [], State0}, []}, Batch),
      UpdateNodeClock_DBOp = update_nodeclock_db_op(NodeClock),
      db_write(Config, [UpdateNodeClock_DBOp | lists:reverse(DbOps)]),
      lists:foreach(
        fun({CallerPid, CallerRef}) ->
                CallerPid ! {CallerRef, ok}
        end, Replies),
      case IsBroadcastEnabled of
          true ->
              #swc_config{transport=TMod} = Config,
  
negative.code:             swc_kv:add(DiscardObj, {Id, Counter}, Value)
      end,
      % save the new k/v and remove unnecessary causal information
      AccDBOps1 = strip_save_batch([{SKey, NewObj, DiskObj}], AccDBOps0, State0, write_op),
      AccReplicate1 = [{SKey, NewObj}|AccReplicate0],
      State1 = State0#state{nodeclock=NodeClock1},
      {AccReplicate1, AccDBOps1, State1}.
  
  process_replicate_op({SKey, Obj}, {AccDBOps0, #state{config=Config, nodeclock=NodeClock0} = State0}) ->
      NodeClock1 = swc_kv:add(NodeClock0, Obj),
      State1 = State0#state{nodeclock=NodeClock1},
      % get and fill the causal history of the local key
  