       # Otherwise, we were the ones wishing to halt, so we should just stop.
       {:halted, [:outer | acc]}
       when op != :halt ->
-        do_transform_user(
-          vals,
-          user_acc,
-          user,
-          fun,
-          next_op,
-          next,
-          {:cont, acc},
-          inner,
-          after_fun
-        )
+        do_transform_user(vals, user_acc, next_op, next, {:cont, acc}, funs)
 
       {:halted, [_ | acc]} ->
         next.({:halt, []})

        :erlang.raise(kind, reason, stacktrace)
    else
      {:suspended, vals, next} ->
        do_transform_user(
          :lists.reverse(vals),
          user_acc,
          user,
          fun,
          :cont,
          next,
          inner_acc,
          inner,
          after_fun
        )

      {_, vals} ->
        do_transform_user(
          :lists.reverse(vals),
          user_acc,
          user,
          fun,
          :halt,
          next,
          inner_acc,
          inner,
          after_fun
        )
    end
  end

  defp do_transform_user([], user_acc, user, fun, next_op, next, inner_acc, inner, after_fun) do
    do_transform(user_acc, user, fun, next_op, next, inner_acc, inner, after_fun)
  end

  defp do_transform_user(
         [val | vals],
         user_acc,
         user,
         fun,
         next_op,
         next,
         inner_acc,
         inner,
         after_fun
       ) do
    user.(val, user_acc)
  catch
    kind, reason ->
      stacktrace = System.stacktrace()
      next.({:halt, []})
      do_after(after_fun, user_acc)
      :erlang.raise(kind, reason, stacktrace)
  else
    {[], user_acc} ->
      do_transform_user(vals, user_acc, user, fun, next_op, next, inner_acc, inner, after_fun)

    {list, user_acc} when is_list(list) ->
      do_list_transform(
        vals,
        user_acc,
        user,
        fun,
        next_op,
        next,
        inner_acc,
        inner,
        &Enumerable.List.reduce(list, &1, fun),
        after_fun
      )

    {:halt, user_acc} ->
      next.({:halt, []})
      do_after(after_fun, user_acc)
      {:halted, elem(inner_acc, 1)}

    {other, user_acc} ->
      do_enum_transform(
        vals,
        user_acc,
        user,
        fun,
        next_op,
        next,
        inner_acc,
        inner,
        &Enumerable.reduce(other, &1, inner),
        after_fun
      )
  end

  defp do_list_transform(
         vals,
         user_acc,
         user,
         fun,
         next_op,
         next,
         inner_acc,
         inner,
         reduce,
         after_fun
       ) do
    try do
      reduce.(inner_acc)
    catch

        :erlang.raise(kind, reason, stacktrace)
    else
      {:done, acc} ->
        do_transform_user(vals, user_acc, next_op, next, {:cont, acc}, funs)

      {:halted, acc} ->
        next.({:halt, []})
        do_after(after_fun, user_acc)
        {:halted, acc}

      {:suspended, acc, continuation} ->
        resume = &do_list_transform(vals, user_acc, next_op, next, &1, continuation, funs)
        {:suspended, acc, resume}
    end
  end

  defp do_enum_transform(vals, user_acc, next_op, next, {op, inner_acc}, reduce, funs) do
    {_, _, _, after_fun} = funs

    try do
      reduce.({op, [:outer | inner_acc]})
    catch
