anchor.diff:  fold_meta_to_bin(?MD_DELETED, _, {{Vt,_Del,Lm},RestBin}) ->
       {{Vt, <<0>>, Lm}, RestBin};
   fold_meta_to_bin(Key, Value, {{_Vt,_Del,_Lm}=Elems,RestBin}) ->
  -    ValueBin = encode_maybe_binary(Value),
  +    {ValueBin, _NewMeta} = encode_maybe_binary(Value, []),
       ValueLen = byte_size(ValueBin),
  -    KeyBin = encode_maybe_binary(Key),
  +    {KeyBin, _NewMeta} = encode_maybe_binary(Key, []),
       KeyLen = byte_size(KeyBin),
       MetaBin = <<KeyLen:32/integer, KeyBin/binary, ValueLen:32/integer, ValueBin/binary>>,
       {Elems, <<RestBin/binary, MetaBin/binary>>}.
   
  -encode_maybe_binary(Bin) when is_binary(Bin) ->
  -    <<1, Bin/binary>>;
  -encode_maybe_binary(Bin) ->
  -    <<0, (term_to_binary(Bin))/binary>>.
  -
  +encode_maybe_binary(Value, Meta) when is_binary(Value) ->
  +    {TypeTag, NewMeta} = determine_binary_type(Meta),
  +    {<<TypeTag, Value/binary>>, NewMeta};
  +encode_maybe_binary(Value, Meta) ->
  +    {<<0, (term_to_binary(Value))/binary>>, Meta}.
  +
  +determine_binary_type(Meta) ->
  +    case dict:find(?VAL_ENCODING, Meta) of
  +        error -> {1, Meta};
  +        {ok, Val} -> {Val, dict:erase(?VAL_ENCODING, Meta)}
  +    end.
   decode_maybe_binary(<<1, Bin/binary>>) ->
       Bin;
   decode_maybe_binary(<<0, Bin/binary>>) ->
  -    binary_to_term(Bin).
  +    binary_to_term(Bin);
  +decode_maybe_binary(<<_Other:8, Bin/binary>>) ->
  +    Bin.
   
   %% Update X-Riak-VTag and X-Riak-Last-Modified in the object's metadata, if
   %% necessary.
  
positive.code:     B = <<"buckets_are_binaries">>,
      K = <<"keys are binaries">>,
      V = <<"values are anything">>,
      O = riak_object:new(B,K,V),
      B = riak_object:bucket(O),
      K = riak_object:key(O),
      V = riak_object:get_value(O),
  
negative.code: -type index_value() :: integer() | binary().
  -type binary_version() :: v0 | v1.
  
  -define(VAL_ENCODING, <<"val-encoding">>).
  -define(MAX_KEY_SIZE, 65536).
  
  -define(LASTMOD_LEN, 29). %% static length of rfc1123_date() type. Hard-coded in Erlang.
  