     receive do
       {:input, ^input, code} when is_binary(code) ->
         send evaluator, {:eval, self(), code, state}
-        wait_eval(evaluator, evaluator_ref)
+        wait_eval(state, evaluator, evaluator_ref)
       {:input, ^input, {:error, :interrupted}} ->
         io_error "** (EXIT) interrupted"
         loop(%{state | cache: ''}, evaluator, evaluator_ref)

    end
  end

  defp wait_eval(evaluator, evaluator_ref) do
    receive do
      {:evaled, ^evaluator, state} ->
        loop(state, evaluator, evaluator_ref)
      msg ->
        handle_take_over(msg, evaluator, evaluator_ref, nil,
                         fn -> wait_eval(evaluator, evaluator_ref) end)
    end
  end



  defp run(opts) when is_list(opts) do
    IO.puts "Interactive Elixir (#{System.version}) - press Ctrl+C to exit (type h() ENTER for help)"
    evaluator = start_evaluator(opts)
    loop(run_state(opts), evaluator, Process.monitor(evaluator))
  end

  defp start_evaluator(opts) do
    self_pid = self()
    self_leader = Process.group_leader
    evaluator = opts[:evaluator] ||
                :proc_lib.start(IEx.Evaluator, :init, [:ack, self_pid, self_leader, opts])
    Process.put(:evaluator, evaluator)
    evaluator
  end

  defp reset_loop(opts, evaluator, evaluator_ref) do
