anchor.diff:  
   %% @private
   init([]) ->
  -    Store = dict:new(),
  -
  -    %% Seed the random number generator using the deterministic seed.
  +    %% Seed the random number generator.
       partisan_config:seed(),
   
       %% Register membership update callback.
       partisan_peer_service:add_sup_callback(fun ?MODULE:update/1),
   
       %% Start with initial membership.
  -    {ok, Membership} = partisan_peer_service:members(),
  -    partisan_logger:info("Starting with membership: ~p", [Membership]),
  -
  -    {ok, #state{membership=Membership, store=Store}}.
  +    {ok, Membership0} = partisan_peer_service:members(),
  +    partisan_logger:info("Starting with membership: ~p", [Membership0]),
  +
  +    %% Initialization values.
  +    Store = dict:new(),
  +    Membership = membership(Membership0),
  +    Outstanding = dict:new(),
  +
  +    {ok, #state{store=Store,
  +                membership=Membership,
  +                outstanding=Outstanding}}.
   
   %% @private
   handle_call(_Msg, _From, State) ->
  
positive.code: 
  %% @private
  handle_cast({update, Membership0}, State) ->
      Membership = lists:usort(Membership0), %% Must sort list or random selection with seed is *nondeterministic.*
      {noreply, State#state{membership=Membership}};
  
  handle_cast({write, {FromPid, FromRequestId}=From, Key, Value}, #state{membership=[Primary, Collaborator|_Rest], store=Store0}=State) ->
      case node() of 
          Primary ->
              partisan_logger:info("~p: node ~p received write for key ~p with value ~p", [?MODULE, node(), Key, Value]),
  
              %% Write value locally.
              Store = write(Key, Value, Store0),
  
              %% Forward to collaboration message.
              Myself = pnode(),
              psend(Collaborator, {collaborate, From, Myself, Key, Value}),
              partisan_logger:info("~p: node ~p sent replication request for key ~p with value ~p", [?MODULE, node(), Key, Value]),
  
              %% Wait for collaboration ack before proceeding for n-host resilience (n = 2).
              receive
                  {collaborate_ack, From, Key, Value} ->
                      partisan_logger:info("~p: node ~p ack received for key ~p value ~p", [?MODULE, node(), Key, Value]),
  
                      %% Reply to caller.
                      psend(FromPid, {response, FromRequestId, ok}),
  
                      {noreply, State#state{store=Store}}
              after
                  %% We have to timeout, otherwise we block the gen_server.
                  ?PB_RETRY_TIMEOUT ->
                      %% Reply to caller.
                      psend(FromPid, {response, FromRequestId, {error, timeout}}),
  
                      {noreply, State}
              end;
          _ ->
              %% Forward the write request to the primary.
              psend(Primary, {forwarded_write, From, Key, Value}),
  
              %% Return control, because backup requests may arrive before response does 
              %% under concurrent scheduling.
              {noreply, State}
      end;
  %% @private
  handle_cast({read, {FromPid, FromRequestId}=From, Key}, #state{membership=[Primary|_Rest], store=Store}=State) ->
      case node() of 
          Primary ->
              Value = read(Key, Store),
              partisan_logger:info("~p: node ~p received read for key ~p and returning value ~p", [?MODULE, node(), Key, Value]),
  
              %% Send the response back to the user.
              psend(FromPid, {response, FromRequestId, {ok, Value}}),
  
              {noreply, State};
          _ ->
              %% Forward the read request to the primary.
              psend(Primary, {forwarded_read, From, Key}),
  
              %% Return control, because backup requests may arrive before response does 
              %% under concurrent scheduling.
              {noreply, State}
      end;
  handle_cast(_Msg, State) ->
      {noreply, State}.
  
  %% @private
  handle_info({forwarded_write, {FromPid, FromRequestId}=From, Key, Value}, #state{membership=[_Primary|Backups], store=Store0}=State) ->
      %% Figure 2c: I think this algorithm is not correct, but we'll see.
  
      Store = write(Key, Value, Store0),
      partisan_logger:info("~p: node ~p received forwarded write for key ~p with value ~p", [?MODULE, node(), Key, Value]),
  
      %% Send backup message to backups.
      lists:foreach(fun(Backup) -> psend(Backup, {backup, From, Key, Value}) end, Backups),
  
      %% Send the response to the caller.
      psend(FromPid, {response, FromRequestId, ok}),
  
      %% No need to send acknowledgement back to the forwarder: 
      %%  - not needed for control flow.
  
      {noreply, State#state{store=Store}};
  
  %% @private
  handle_info({forwarded_read, {FromPid, FromRequestId}, Key}, #state{store=Store}=State) ->
      Value = read(Key, Store),
      partisan_logger:info("~p: node ~p received forwarded read for key ~p and returning value ~p", [?MODULE, node(), Key, Value]),
  
      %% Send the response to the caller.
      psend(FromPid, {response, FromRequestId, {ok, Value}}),
  
      %% No need to send acknowledgement back to the forwarder: 
      %%  - not needed for control flow.
  
      {noreply, State};
  
  %% @private
  handle_info({collaborate, {FromPid, FromRequestId}=From, SourceNode, Key, Value}, #state{membership=[_Primary, _Collaborator | Backups], store=Store0}=State) ->
      %% Write value locally.
      Store = write(Key, Value, Store0),
      partisan_logger:info("~p: node ~p storing updated value key ~p value ~p", [?MODULE, node(), Key, Value]),
  
      %% On ack, reply to caller.
      psend(FromPid, {response, FromRequestId, ok}),
  
      %% Send write acknowledgement.
      psend(SourceNode, {collaborate_ack, From, Key, Value}),
      partisan_logger:info("~p: node ~p acknowledging value for key ~p value ~p", [?MODULE, node(), Key, Value]),
  
      %% Send backup message to backups.
      lists:foreach(fun(Backup) -> psend(Backup, {backup, From, Key, Value}) end, Backups),
  
      {noreply, State#state{store=Store}};
  
  %% @private
  handle_info({backup, _From, _SourceNode, Key, Value}, #state{store=Store0}=State) ->
      %% Write value locally.
      Store = write(Key, Value, Store0),
      partisan_logger:info("~p: node ~p storing updated value key ~p value ~p", [?MODULE, node(), Key, Value]),
  
      {noreply, State#state{store=Store}};
  
  %% @private
  handle_info(_Msg, State) ->
      {noreply, State}.
  
  %% @private
  
negative.code: %% @private
  code_change(_OldVsn, State, _Extra) ->
      {ok, State}.
  
  %%%===================================================================
  %%% Internal functions
  