   end
 
   # Rows
-  defp decode_result_response(<<0x0002::32-signed>> <> rest, query) do
+  defp decode_result_response(<<0x0002::32-signed>> <> buffer, query) do
     rows = case query.prepared do
       {_query_id, rows} -> rows
       nil -> %Rows{}
     end
-    {rows, rest} = decode_metadata(rows, rest)
-    content = decode_rows_content(rest, rows.column_specs)
+    {rows, buffer} = decode_metadata(rows, buffer)
+    content = decode_rows_content(buffer, rows.column_specs)
     %{rows | content: content}
   end
 
-  defp decode_result_response(<<0x0003::32-signed>> <> rest, _query) do
-    {keyspace, ""} = decode_string(rest)
+  defp decode_result_response(<<0x0003::32-signed>> <> buffer, _query) do
+    {keyspace, ""} = decode_string(buffer)
     %Xandra.SetKeyspace{keyspace: keyspace}
   end
 
   # Prepared
-  defp decode_result_response(<<0x0004::32-signed>> <> rest, query) do
-    {query_id, rest} = decode_string(rest)
-    {_rows, rest} = decode_metadata(%Rows{}, rest)
-    {rows, <<>>} = decode_metadata(%Rows{}, rest)
+  defp decode_result_response(<<0x0004::32-signed>> <> buffer, query) do
+    {query_id, buffer} = decode_string(buffer)
+    {_rows, buffer} = decode_metadata(%Rows{}, buffer)
+    {rows, <<>>} = decode_metadata(%Rows{}, buffer)
     %{query | prepared: {query_id, rows}}
   end
 
-  defp decode_result_response(<<0x0005::32-signed>> <> rest, _query) do
-    {effect, rest} = decode_string(rest)
-    {target, rest} = decode_string(rest)
-    options = decode_change_options(rest, target)
+  defp decode_result_response(<<0x0005::32-signed>> <> buffer, _query) do
+    {effect, buffer} = decode_string(buffer)
+    {target, buffer} = decode_string(buffer)
+    options = decode_change_options(buffer, target)
     %Xandra.SchemaChange{effect: effect, target: target, options: options}
   end
 

  end

  defp decode_paging_state(rows, 1, buffer) do
    <<byte_count::32, paging_state::bytes-size(byte_count)>> <> rest = buffer
    {%{rows | paging_state: paging_state}, rest}
  end

  defp decode_rows_content(<<row_count::32-signed>> <> buffer, column_specs) do

  end

  defp decode_change_options(buffer, target) when target in ["TABLE", "TYPE"] do
    {keyspace, buffer} = decode_string(buffer)
    {subject, ""} = decode_string(buffer)
    %{keyspace: keyspace, subject: subject}
  end

  defp decode_metadata(rows, <<flags::4-bytes, column_count::32-signed>> <> buffer) do
    <<_::29, no_metadata::1, has_more_pages::1, global_table_spec::1>> = flags
    {rows, buffer} = decode_paging_state(rows, has_more_pages, buffer)

    cond do
      no_metadata == 1 ->
        {rows, buffer}
      global_table_spec == 1 ->
        {keyspace_name, buffer} = decode_string(buffer)
        {table_name, buffer} = decode_string(buffer)
        {column_specs, buffer} = decode_column_specs(buffer, column_count, {keyspace_name, table_name}, [])
        {%{rows | column_specs: column_specs}, buffer}
      true ->
        {column_specs, buffer} = decode_column_specs(buffer, column_count, nil, [])
        {%{rows | column_specs: column_specs}, buffer}
    end
  end

