         Process.delete(:iex_server)
       end
 
-      cond do
-        is_nil(evaluator) ->
-          Process.delete(:iex_evaluator)
-
-        evaluator != :ack ->
-          # Ensure propagation to non-root level evaluators
-          send(self(), {:done, server})
-
-        true ->
-          :ok
+      if old_evaluator do
+        Process.put(:iex_evaluator, old_evaluator)
+      else
+        Process.delete(:iex_evaluator)
       end
 
       :ok

    end
  end

  defp loop(%{server: server} = state) do
    receive do
      {:eval, ^server, code, iex_state} ->
        {result, state} = eval(code, iex_state, state)


  """
  def init(command, server, leader, opts) do
    ref = make_ref()
    old_leader = Process.group_leader()
    Process.group_leader(self(), leader)

    old_server = Process.get(:iex_server)
    Process.put(:iex_server, server)

    old_evaluator = Process.get(:iex_evaluator)
    Process.put(:iex_evaluator, ref)

    if old_evaluator do
      send(self(), {:done, old_evaluator})
    end

    state = loop_state(ref, server, IEx.History.init(), opts)
    command == :ack && :proc_lib.init_ack(self())

    try do
