     clauses = [struct_clause_for(line) | clauses] ++
               [fallback_clause_for(fallback, protocol, line)]
 
-    change_impl_for(t, protocol, types, structs, is_protocol,
+    change_impl_for(tail, protocol, types, structs, protocol?,
                     [{:function, line, :impl_for, 1, clauses} | acc])
   end
 
-  defp change_impl_for([{:function, line, :struct_impl_for, 1, _} | t], protocol, types, structs, is_protocol, acc) do
+  defp change_impl_for([{:function, line, :struct_impl_for, 1, _} | tail], protocol, types, structs, protocol?, acc) do
     fallback = if Any in types, do: load_impl(protocol, Any)
     clauses = for struct <- structs, do: each_struct_clause_for(struct, protocol, line)
     clauses = clauses ++ [fallback_clause_for(fallback, protocol, line)]
 
-    change_impl_for(t, protocol, types, structs, is_protocol,
+    change_impl_for(tail, protocol, types, structs, protocol?,
                     [{:function, line, :struct_impl_for, 1, clauses} | acc])
   end
 
-  defp change_impl_for([{:attribute, line, :spec, {{:__protocol__, 1}, funspecs}} | t], protocol, types, structs, is_protocol, acc) do
-    newspecs = for spec <- funspecs do
+  defp change_impl_for([{:attribute, line, :spec, {{:__protocol__, 1}, funspecs}} | tail], protocol, types, structs, protocol?, acc) do
+    new_specs = for spec <- funspecs do
       case spec do
         {:type, line, :fun, [{:type, _, :product, [{:atom, _, :consolidated?}]}, _]} ->
           {:type, line, :fun,

        other -> other
      end
    end
    change_impl_for(t, protocol, types, structs, is_protocol, [{:attribute, line, :spec, {{:__protocol__, 1}, newspecs}}|acc])
  end

  defp change_impl_for([h | t], protocol, info, types, is_protocol, acc) do
    change_impl_for(t, protocol, info, types, is_protocol, [h | acc])
  end

  defp change_impl_for([], protocol, _info, _types, is_protocol, acc) do
    if is_protocol do
      {:ok, {protocol, Enum.reverse(acc)}}
    else
      {:error, :not_a_protocol}

    end
  end

  defp change_impl_for([{:function, line, :__protocol__, 1, clauses} | tail], protocol, types, structs, _, acc) do
    clauses = :lists.map(fn
      {:clause, l, [{:atom, _, :consolidated?}], [], [{:atom, _, _}]} ->
        {:clause, l, [{:atom, 0, :consolidated?}], [], [{:atom, 0, true}]}
