       field, acc when is_record(field, :named_field) ->
         named_field(data_type: type, data_ptr: ptr) = field
 
-        IO.puts "Decoding field: #{inspect field}..."
-
         if ptr == 0 do
           {{field, nil}, acc}
         else
           {value, rest} = decode_type(acc, type)
-          IO.puts "decoded field #{inspect field} with value #{inspect value}"
-          IO.puts "what comes next: #{inspect rest}"
           {{field, value}, rest}
         end
     end

  @spec decode(binary) :: {non_neg_integer, String.t, %{}}
  def decode(data) do
    <<_version, rest :: binary>> = data
    decode_document(rest)
  end

  defp decode_document(data) do

        property = property(id: decode_property_id(i), data_ptr: data_ptr)
        decode_header_fields(rest, [property|acc])
      i > 0 ->
        {field_name, rest}            = decode_type(data, :string)
        {data_ptr, rest}              = decode_data_ptr(rest)
        <<data_type, rest :: binary>> = rest
        field = named_field(name: field_name, data_type: int_to_type(data_type), data_ptr: data_ptr)

        decode_header_fields(rest, [field|acc])
    end
