anchor.diff:      end;
   update_crdt(Dict, Actor, ?CRDT_OP{mod=Mod, op=Ops, ctx=OpCtx}) when Mod==?MAP_TYPE;
                                                                       Mod==?SET_TYPE->
  -    Ctx = context_to_crdt(Mod, OpCtx),
  -    {PreOps, PostOps} = split_ops(Ops),
  -    %% Apply Pre (remove) ops to the context
  -    case Mod:update(PreOps, Actor, Ctx) of
  -        {error, _}=E -> E;
  -        {ok, InitialVal} ->
  -            %% Merge with local replica and then apply post (add) ops
  -            case orddict:find(Mod, Dict) of
  -                error ->
  +    case orddict:find(Mod, Dict) of
  +        error ->
  +            %% No local replica of this CRDT, apply the ops to a new
  +            %% instance
  +            case update_crdt(Mod, Ops, Actor, Mod:new(), OpCtx) of
  +                {ok, InitialVal} ->
                       orddict:store(Mod, {undefined, to_record(Mod, InitialVal)}, Dict);
  -                {ok, {Meta, LocalCRDT=?CRDT{value=LocalReplica}}} ->
  -                    case Mod:update(PostOps, Actor, LocalReplica) of
  -                        {error, _}=E -> E;
  -                        {ok, NewVal} ->
  -                            Merged = Mod:merge(InitialVal, NewVal),
  -                            orddict:store(Mod, {Meta, LocalCRDT?CRDT{value=Merged}}, Dict)
  -                    end
  +                E ->
  +                    E
  +            end;
  +        {ok, {Meta, LocalCRDT=?CRDT{value=LocalReplica}}} ->
  +            case update_crdt(Mod, Ops, Actor, LocalReplica, OpCtx) of
  +                {error, _}=E -> E;
  +                {ok, NewVal} ->
  +                    orddict:store(Mod, {Meta, LocalCRDT?CRDT{value=NewVal}}, Dict)
               end
       end.
   
  --spec context_to_crdt(module(), undefined | binary()) -> riak_dt:crdt().
  -context_to_crdt(Mod, undefined) ->
  -    Mod:new();
  -context_to_crdt(Mod, Ctx) ->
  -    Mod:from_binary(Ctx).
  +%% @private call update/3 or update/4 depending on context value
  +-spec update_crdt(module(), term(), riak_dt:actor(), term(),
  +                  undefined | riak_dt_vclock:vclock()) ->
  +                         term().
  +update_crdt(Mod, Ops, Actor, CRDT, undefined) ->
  +    Mod:update(Ops, Actor, CRDT);
  +update_crdt(Mod, Ops, Actor, CRDT, Ctx0) ->
  +    Ctx = get_context(Ctx0),
  +    Mod:update(Ops, Actor, CRDT, Ctx).
  +
  +-spec get_context(undefined | binary()) -> riak_dt_vclock:vclock().
  +get_context(undefined) ->
  +    undefined;
  +get_context(Bin) ->
  +    riak_dt_vclock:from_binary(Bin).
   
   %% @doc get the merged CRDT for type `Mod' from the dictionary. If it
   %% is not present generate a default entry
  
positive.code: 
  -define(TEST_TIME_SECONDS, 10).
  
  eqc_test_() ->
      {timeout, ?TEST_TIME_SECONDS+5, [?_assert(test_split() =:= true)]}.
  
  test_split() ->
      test_split(?TEST_TIME_SECONDS).
  
  test_split(TestTimeSeconds) ->
      eqc:quickcheck(eqc:testing_time(TestTimeSeconds, ?QC_OUT(prop_split()))).
  
  prop_split() ->
      ?FORALL(Ops, oneof([riak_dt_map:gen_op(), riak_dt_orswot:gen_op()]),
              begin
                  {Pre, Post} = split_ops(Ops),
                  AgOps = to_list(Ops),
                  ?WHENFAIL(
                     begin
                         io:format("Generated Ops ~p~n", [Ops]),
                         io:format("Split Pre ~p~n", [Pre]),
                         io:format("Split Post ~p~n", [Post])
                     end,
                     collect(with_title("operation length"), length(AgOps),
                             collect(with_title("operation depth"), depth(AgOps, 0),
                                     conjunction([
                                                  {pre, only_rem_ops(Pre)},
                                                  {post, only_add_ops(Post)}
                                                 ])))
                    )
              end).
  
  to_list({update, Ops}) ->
      Ops;
  to_list(Op) ->
      [Op].
  
  depth({update, Ops}, Depth) ->
      depth(Ops, Depth);
  depth([], Depth) ->
      Depth;
  depth([{update, {_Name, ?MAP_TYPE}, {update, Ops}}| Rest], Depth) ->
      max(depth(Ops, Depth +1), depth(Rest, Depth));
  depth([_Op | Rest], Depth) ->
      depth(Rest, Depth).
  
  only_type_ops(_TestFun, []) ->
      true;
  only_type_ops(TestFun, [Op | Rest]) ->
      case TestFun(Op) of
          false ->
              false;
          true ->
              only_type_ops(TestFun, Rest)
      end.
  
  only_add_ops({update, Ops}) ->
      only_add_ops(Ops);
  only_add_ops(Ops) ->
      only_type_ops(fun is_add_op/1, Ops).
  
  only_rem_ops({update, Ops}) ->
      only_rem_ops(Ops);
  only_rem_ops(Ops) ->
      only_type_ops(fun is_rem_op/1, Ops).
  
  is_add_op({update, {_Name, _}, {update, Ops}}) ->
      only_add_ops(Ops);
  is_add_op(Op) ->
      not is_rem_op(Op).
  
  is_rem_op({update, {_Name, _}, {update, Ops}}) ->
      only_rem_ops(Ops);
  is_rem_op({update, {_Name, _}, {remove, _E}}) ->
      true;
  is_rem_op({update, {_Name, _}, {remove_all, _Es}}) ->
      true;
  is_rem_op({remove, _Key}) ->
      true;
  is_rem_op({remove_all, _Elems}) ->
      true;
  is_rem_op({update, _Key, {remove, _Elem}}) ->
      true;
  is_rem_op(_Op) ->
      false.
  
  -endif.
  -endif.
  
negative.code: %% a smaller than Type:to_binary(Value) binary context.
  get_context(Type, Value) ->
      case lists:member({precondition_context, 1}, Type:module_info(exports)) of
          true -> riak_dt_vclock:to_binary(Type:precondition_context(Value));
          false -> <<>>
      end.
  
  