anchor.diff:  encode_channel_type(Other) -> Other.
   
   %% Tagged types
  -encode_obj(?raw(Data)) ->
  -    Data;
  -encode_obj(?map(Data)) ->
  -    [?VARINT_MAP,encode_map(Data)];
  -encode_obj(?array(Data)) ->
  -    [?VARINT_ARRAY,encode_array(Data)];
  -encode_obj(?error(Code,Msg)) ->
  -    [?VARINT_ERROR,encode_type(svarint32,Code),encode_obj(Msg)];
  -encode_obj(?bytes(Data)) ->
  -    [?VARINT_BYTES,encode_type(bytes,Data)];
  -encode_obj(?byte(Byte)) ->
  -    [?BYTE,Byte];
  -encode_obj(?uuid(Data)) ->
  -    [?UUID,encode_type(uuid,Data)];
  -encode_obj(?secid(Data)) ->
  -    [?SECID,encode_type(secid,Data)];
  -encode_obj(?time(Data)) ->
  -    [?VARINT_TIME,encode_type(date,Data)];
  -%% exact types
  -encode_obj(true) -> [?TRUE];
  -encode_obj(false) -> [?FALSE];
  -encode_obj(undefined) -> [?NULL];
  -encode_obj(null) -> [?NULL];
  -encode_obj(nil) -> [?NULL];
  -%% inferred types
  -encode_obj(Obj) when is_integer(Obj), Obj < 0 ->
  -    [?SVARINT64,encode_type(svarint64,Obj)];
  -encode_obj(Obj) when is_integer(Obj) ->
  -    [?VARINT64,encode_type(varint64,Obj)];
  -encode_obj(Obj) when is_float(Obj) ->
  -    [?DOUBLE,encode_type(double,Obj)];
  -encode_obj(Obj) when is_atom(Obj) ->
  -    [?VARINT_STRING,encode_type(string,Obj)];
  -encode_obj(Obj) when is_binary(Obj) ->
  -    [?VARINT_STRING,encode_type(string,Obj)];
  -encode_obj(Obj) when is_list(Obj) ->
  -    [?VARINT_ARRAY,encode_type(array,Obj)];
  -encode_obj(Obj) when is_tuple(Obj) ->
  -    [?VARINT_ARRAY,encode_type(array,Obj)].
  +encode_obj(?raw(Data)) -> Data;
  +encode_obj(Data) -> encode_obj(v1_1, Data).
  +
  +encode_obj(v1_1, Obj) when is_binary(Obj) ->
  +    [?FAST_STRING, encode_obj(size(Obj)), Obj];
  +encode_obj(v1_1, 0) -> ?INT0;
  +encode_obj(v1_1, Obj) when is_integer(Obj) ->
  +    case Obj of
  +        O when O >= -128 andalso O < 128 -> [?INT1, <<O:8/signed>>];
  +        O when O > 0 andalso O < 256 -> [?UINT1, <<O:8>>];
  +        O when O >= -32768 andalso O < 32768 -> [?INT2, <<O:16/signed>>];
  +        O when O > 0 andalso O < 65536 -> [?UINT2, <<O:16>>];
  +        O when O >= -2147483648 andalso O < 2147483648 ->
  +            [?INT4, <<O:32/signed>>];
  +        O when O > 0 andalso O < 4294967296 -> [?UINT4, <<O:32>>];
  +        O when O >= -9223372036854775808 andalso
  +               O < 9223372036854775808 ->
  +            [?INT8, <<O:64/signed>>];
  +        O when O > 0 andalso O < 18446744073709551616 -> [?UINT8, <<O:64>>];
  +        O -> ?lerr("Int too big to mmd encode: ~p", [O]), O
  +    end;
  +encode_obj(_, Obj) when is_float(Obj) ->
  +    [?DOUBLE, encode_type(double, Obj)];
  +encode_obj(Vsn, Obj) when is_atom(Obj) ->
  +    encode_obj(Vsn, atom_to_binary(Obj, utf8));
  +
  +encode_obj(_, true) -> [?TRUE];
  +encode_obj(_, false) -> [?FALSE];
  +encode_obj(_, undefined) -> [?NULL];
  +encode_obj(_, null) -> [?NULL];
  +encode_obj(_, nil) -> [?NULL];
  +
  +encode_obj(Vsn, ?map(Data)) ->
  +    {Sz, Body} = encode_map(Vsn, Data),
  +    case Vsn of
  +        v1_1 -> [?FAST_MAP, encode_obj(Sz), Body];
  +        v1_0 -> [?VARINT_MAP, encode_varint(Sz), Body]
  +    end;
  +encode_obj(Vsn, ?array(Data)) ->
  +    {Sz, Body} = encode_array(Vsn, Data),
  +    case Vsn of
  +        v1_1 -> [?FAST_ARRAY, encode_obj(Sz), Body];
  +        v1_0 -> [?VARINT_ARRAY, encode_type(varint32, Sz), Body]
  +    end;
  +encode_obj(v1_1, ?error(Code, Msg)) ->
  +    [?VARINT_ERROR, encode_obj(Code), encode_obj(v1_1, Msg)];
  +encode_obj(v1_1, ?bytes(Data)) -> [?FAST_BYTES, encode_obj(size(Data)), Data];
  +encode_obj(_, ?byte(Byte)) ->
  +    [?BYTE, Byte];
  +encode_obj(_, ?uuid(Data)) -> [?UUID, encode_type(uuid, Data)];
  +encode_obj(_, ?secid(Data)) -> [?SECID, encode_type(secid, Data)];
  +encode_obj(v1_1,  ?time(Data)) -> [?FAST_TIME, <<Data:64>>];
  +encode_obj(Vsn, Obj) when is_list(Obj) -> encode_obj(Vsn, ?array(Obj));
  +encode_obj(Vsn, Obj) when is_tuple(Obj) ->
  +    encode_obj(Vsn, ?array(tuple_to_list(Obj)));
  +
  +encode_obj(v1_0, Obj) when is_binary(Obj) ->
  +    [?VARINT_STRING, encode_varint(size(Obj)), Obj];
  +
  +encode_obj(v1_0, ?error(Code, Msg)) ->
  +    [?VARINT_ERROR, encode_type(svarint32, Code), encode_obj(v1_0, Msg)];
  +encode_obj(v1_0, ?bytes(Data)) -> [?VARINT_BYTES, encode_varint(Data), Data];
  +encode_obj(v1_0,  ?time(Data)) -> [?VARINT_TIME, encode_svarint(Data)];
  +encode_obj(v1_0, Obj) when is_integer(Obj), Obj < 0 ->
  +    [?SVARINT64, encode_type(svarint64, Obj)];
  +encode_obj(v1_0, Obj) when is_integer(Obj) ->
  +    [?VARINT64, encode_type(varint64, Obj)].
  +
   
   %% Encodes a given value as the specified type
   %% Note: This does NOT prefix with a type specifier, it's up to the caller
  
positive.code:     p6uuid:parse(UUID);
  encode_type(secid,SecID) when is_binary(SecID) ->
      SecID;
  encode_type(bytes,Bytes) when is_binary(Bytes)->
      [encode_varint(size(Bytes)),Bytes];
  encode_type(string,String) when is_tuple(String) ->
      encode_type(string,p6str:mkstr("~p",String));
  encode_type(string,String) when is_list(String) ->
  
negative.code:     <<Float:32/float>>;
  encode_type(double,Double) ->
      <<Double:64/float>>;
  encode_type(date,D) ->
      encode_svarint(D);
  encode_type(byte,B) ->
  