     map
   end
 
+  def decode_array(_con, _size, 0, <<>>=value_bytes), do: {[], value_bytes}
   def decode_array(con, size, count, value_bytes) do
+    Logger.debug "decode array: size= #{size}, count = #{count}"
     {type, bin} = if con == 0x00 do
       {t, b} = decode_bin(value_bytes)
     else

    Enum.reverse list
  end

  def decode_map(value, count) do
    {map, <<>>} = 1..(div(count, 2)) |>
    Enum.reduce({%{}, value}, fn _, {map, bytes} ->

    typed_decoder(value_bin, type)
  end

  def decode_list(value, 0), do: {[], value}
  def decode_list(value, count) do
    {list, <<>>} = 1..count |>
    Enum.reduce({[], value}, fn _, {l, bytes} ->
