   end
 
   def decode(stream, options \\ []) do
-    { stream, options |> options_with_defaults }
+    stream
+    |> with_default_options(options)
     |> prepare_headers
     |> prepare_row_length
     |> decode_stream

    do: build_row(parsed, headers)
  end

  #defp decode_row({ nil, 0 }, %{ row_length: false }), do: { :ok, [] }

  defp parse_row({ line, index}, options) do
    with { :ok, lex, _ } <- Lexer.lex({ line, index }, options),
    do: Parser.parse({ lex, index }, options)

  end
  defp build_row(data, _), do: { :ok, data }

  defp with_default_options(stream, options) do
    num_pipes = options |> Keyword.get(:num_pipes, Defaults.num_workers)

    options = options
    |> Keyword.merge(num_pipes: num_pipes,
                     num_workers: options |> Keyword.get(:num_workers, num_pipes),
                     multiline_escape: options |> Keyword.get(:multiline_escape, true),
                     headers: options |> Keyword.get(:headers, false),
                     row_length: false)

    { stream, options }
  end

  defp prepare_headers({ stream, options } = payload) do
