   end
 
   def decode_type(data, :embedded_list, schema) do
-    {nitems, rest} = :small_ints.decode_zigzag_varint(data)
+    {nitems, rest}           = :small_ints.decode_zigzag_varint(data)
     <<type, rest :: binary>> = rest
 
     # Only ANY is supported by OrientDB at the moment.
     :any = int_to_type(type)
 
-    # OPTIMIZE: I have to find a better (clean) way to `map_reduce` n times
-    # instead of mapreducing over a list of n times the number 0, which is
-    # uselessly expensive to build and plain useless. A range doesn't work
-    # because `Enum.to_list(1..0)` is `[1, 0]` which makes sense, but my
-    # 1..nitems has to translate to `[]` so that the mapreducing doesn't
-    # actually happen.
-    Enum.map_reduce List.duplicate(0, nitems), rest, fn(_, acc) ->
-      <<type, acc :: binary>> = acc
+    Enum.map_reduce List.duplicate(nil, nitems), rest, fn(_, <<type, acc :: binary>>) ->
       decode_type(acc, int_to_type(type), schema)
     end
   end


    case decode_header(rest, schema) do
      {field_definitions, rest} ->
        {fields, rest} = decode_fields(rest, field_definitions)

        if class_name == "" do
          class_name = nil

      {ptr, acc} = decode_data_ptr(acc)
      <<type, acc :: binary>> = acc

      {field(name: key, type: int_to_type(type), ptr: ptr), acc}
    end
  end

  defp decode_map_values(data, keys, schema) do
    Enum.map_reduce(keys, data, &decode_field(&2, &1, schema))
  end

  defp encode_fields(%{} = fields, offset) do
