anchor.diff:  
   %% @doc Encodes a map operation into a MapOp message.
   -spec encode_map_op(map_op()) -> #mapop{}.
  -encode_map_op({update, Adds, Removes, Updates}) ->
  -    #mapop{
  -       adds=[ encode_map_field(A) || Adds /= undefined, A <- Adds ],
  -       removes=[ encode_map_field(R) || Removes /= undefined, R <- Removes ],
  -       updates=[ encode_map_update(K,O) || Updates /= undefined,
  -                                           {K, O} <- Updates ]}.
  -
  +encode_map_op({update, Ops}) ->
  +    lists:foldr(fun encode_map_op_update/2, #mapop{}, Ops);
  +encode_map_op({Op, _}=C) when add == Op; remove == Op ->
  +    encode_map_op({update, [C]});
  +encode_map_op({update, _Field, _Ops}=C) ->
  +    encode_map_op({update, [C]}).
  +
  +%% @doc Folds a map update into the MapOp message.
  +-spec encode_map_op_update(simple_map_op(), #mapop{}) -> #mapop{}.
  +encode_map_op_update({add, F}, #mapop{adds=A}=M) ->
  +    M#mapop{adds=[encode_map_field(F)|A]};
  +encode_map_op_update({remove, F}, #mapop{removes=R}=M) ->
  +    M#mapop{removes=[encode_map_field(F)|R]};
  +encode_map_op_update({update, F, Ops}, #mapop{updates=U}=M) ->
  +    Updates = [ encode_map_update(F, Op) || Op <- Ops ],
  +    M#mapop{updates=Updates ++ U}.
  +
  +-spec decode_map_op(#mapop{}, type_mappings()) -> map_op().
   decode_map_op(#mapop{adds=Adds, removes=Removes, updates=Updates}, Mods) ->
  -    {update, 
  -     [ decode_map_field(A, Mods) || A <- Adds ],
  -     [ decode_map_field(R, Mods) || R <- Removes ],
  -     [ decode_map_update(U, Mods) || U <- Updates ]}.
  +    {update,
  +     [ {add, decode_map_field(A, Mods)} || A <- Adds ] ++
  +     [ {remove, decode_map_field(R, Mods)} || R <- Removes ] ++
  +     [ begin
  +           {Field, Op} = decode_map_update(U, Mods),
  +           {update, Field, Op}
  +       end || U <- Updates ]}.
   
   %% @doc Decodes a DtOperation message into a datatype-specific operation.
   -spec decode_operation(#dtop{}) -> toplevel_op().
  
positive.code: 
  %% @doc Decodes a SetOp message into a set operation.
  -spec decode_set_op(#setop{}) -> set_op().
  decode_set_op(#setop{adds=A, removes=R}) ->
      {update, A, R}.
  
  %% @doc Encodes a set operation into a SetOp message.
  -spec encode_set_op(set_op()) -> #setop{}.
  encode_set_op({Op, Member}) when is_binary(Member) ->
      encode_set_op({Op, [Member]});
  encode_set_op({add, Members}) when is_list(Members) ->
      #setop{adds=Members};
  encode_set_op({remove, Members}) when is_list(Members) ->
      #setop{removes=Members};
  encode_set_op({update, Adds, Removes}) when is_list(Adds), is_list(Removes) ->
      #setop{adds=Adds, removes=Removes}.
  
  %% @doc Decodes a operation name from a PB message into an atom.
  -spec decode_flag_op(atom()) -> atom().
  
negative.code: 
  %% Operations
  -type counter_op() :: increment | decrement | {increment | decrement, integer()}.
  -type simple_set_op() :: {add, binary()} | {remove, binary()} | {add_all, [binary()]} | {remove_all, [binary()]}.
  -type set_op() :: simple_set_op() | {update, [simple_set_op()]}.
  -type flag_op() :: enable | disable.
  -type register_op() :: {assign, binary()}.
  -type simple_map_op() :: {add, map_field()} | {remove, map_field()} | {update, map_field(), [embedded_type_op()]}.
  -type map_op() :: simple_map_op() | {update, [simple_map_op()]}.
  -type embedded_type_op() :: counter_op() | set_op() | register_op() | flag_op().
  -type toplevel_op() :: counter_op() | set_op() | map_op().
  
  