anchor.diff:  close_and_delete(State) -> ?PDB:close_and_delete(State).
   
   -spec on(tuple(), state()) -> state().
  +%% Procedure ReceiveValue
   on({zheng_acceptor, new_read, _Cons, Proposer, Key, ReqId, DataType, QueryFuns}, State) ->
  -    comm:send_local(self(),
  -      {zheng_acceptor, new_write, _Cons, Proposer, Key, ReqId, DataType, {qfun, QueryFuns}}),
  +    ?TRACE("~p NEW QUERY COMMAND ~p ~p~n~p", [Key, Proposer, ReqId, QueryFuns]),
  +    PState = get_pstate(Key, State),
  +
  +    {Cid, NP1} = get_new_id(Key, PState),
  +    QueryCmd = new_query_cmd(Cid, QueryFuns),
  +    Client = new_client(ReqId, Proposer),
  +
  +    NP2 = add_to_notify(Client, QueryCmd, NP1),
  +    NP3 = ?add(buff_val, QueryCmd, NP2),
  +    save_pstate(Key, NP3, State),
  +
  +    comm:send_local(self(), {zheng_acceptor, agree, Key, DataType}),
       State;
   
   
  -%% Procedure ReceiveValue
   on({zheng_acceptor, new_write, _Cons, Proposer, Key, ReqId, DataType, UpdateFuns}, State) ->
  -    ?TRACE("NEW WRITE ~p ~p", [Proposer, ReqId]),
  +    ?TRACE("~p NEW WRITE COMMAND ~p ~p~n~p", [Key, Proposer, ReqId, UpdateFuns]),
       PState = get_pstate(Key, State),
  -    NewPState = ?add(buff_val, {ReqId, Proposer}, UpdateFuns, PState),
  -    save_pstate(Key, NewPState, State),
  +
  +    {Cid, NP1} = get_new_id(Key, PState),
  +    UpdateCmd = new_update_cmd(Cid, UpdateFuns),
  +    Client = new_client(ReqId, Proposer),
  +
  +    NP2 = add_to_notify(Client, UpdateCmd, NP1),
  +    NP3 = ?add(buff_val, UpdateCmd, NP2),
  +    save_pstate(Key, NP3, State),
  +
       comm:send_local(self(), {zheng_acceptor, agree, Key, DataType}),
       State;
   
  
positive.code:     accept_val = new_buffer() :: buffer(),
      active = false :: boolean(),
  
      crdt_type = null :: null | crdt:crdt_module(),
      cmd_set = new_buffer() :: buffer(),
      crdt = null :: null | crdt:crdt(),
      replies = #replies{} :: #replies{} | done,
  
      loop_val = null :: buffer(),
      loop_iter = null :: non_neg_integer(),
  
      prop_wait_list = [] :: [tuple()]
    }).
  
  %% More sensible management of query commands... these do not have to be sent
  %% to remotely as they are noops for updates?
  
  -type buffer() :: set:sets(buffer_element()).
  -type buffer_element() ::
    {comm:mypid(),
      {qfun, crdt:query_fun() | [crdt:query_fun()]}
      | [crdt:update_fun()]}.
  
  %% initialize: return initial state.
  -spec init(atom() | tuple()) -> state().
  
negative.code:     "crdt:~p~n" ++
      "replies:~p~n"
      ,
      [_Msg, _Key,
      ?get(seq, _PState),
      ?get(max_seq, _PState),
      ?get(buff_val, _PState),
      ?get(learned_val, _PState),
      ?get(accept_val, _PState),
      ?get(active, _PState),
  
      ?get(cmd_set, _PState),
      ?get(crdt_type, _PState),
      ?get(crdt, _PState),
      ?get(replies, _PState)
      ]).
  
  