     {data_ptr, rest}              = decode_data_ptr(rest)
     <<data_type, rest :: binary>> = rest
 
-    # field = %Field{name: field_name, type: int_to_type(data_type), pointer_to_data: data_ptr}
-
     field = field_def(name: field_name, type: int_to_type(data_type), ptr: data_ptr)
     {field, rest}
   end
 
-  # Decodes fields from the body of a serialized document (`data`) and a list of
-  # `%Field{}` structs (with no `:value` field, they're definitions). Returns a
-  # list of `%Field{}`s and the rest of the given data.
   defp decode_fields(data, field_definitions) do
     {fields, rest} = Enum.map_reduce field_definitions, data, fn(field_def(name: name) = f, acc) ->
       if field_def(f, :ptr) == 0 do

  Record.defrecordp :typed_field, [:value, :type]

  Record.defrecordp :field_def, [:name, :ptr, :type]

  defmodule Field do
    @type t :: %__MODULE__{
      name: binary,
      type: atom,
      pointer_to_data: non_neg_integer,
      value: term,
      encoded_value: iodata,
    }

    defstruct ~w(name type pointer_to_data value encoded_value)a
  end

  @doc """
  Parses a binary-serialized record.

    # {{class_name, fields}, rest}
  end

  defp decode_header(data, acc \\ []) do
    {i, rest} = :small_ints.decode_zigzag_varint(data)

