           stacktrace = System.stacktrace
           io.error "** (#{inspect exception.__record__(:name)}) #{exception.message}"
           print_stacktrace io, stacktrace
-          config.cache('')
+          {config.cache(''), history}
       catch
         kind, error ->
           stacktrace = System.stacktrace
           io.error "** (#{kind}) #{inspect(error)}"
           print_stacktrace io, stacktrace
-          config.cache('')
+          {config.cache(''), history}
       end
 
-    do_loop(new_config)
+    do_loop(new_config, history)
   end
 
   defp print_stacktrace(io, stacktrace) do

    cache   = config.cache
    code    = cache ++ io.get(cache, counter)

    new_config =
      try do
        { result, new_binding, scope } =
          Erlang.elixir.eval(code, config.binding, counter, config.scope)
        io.put result
        config.binding(new_binding).cache('').scope(scope)
      rescue
        TokenMissingError ->
          config.cache(code)

  def m(mod) do
    IO.inspect mod.module_info
  end

  @doc """
  Prints the history
  """
  def h do
    history = List.reverse(Process.get(:__history__))
    lc {item, index} inlist List.zip(history,
                            :lists.seq(1,length(history))) do
      IO.puts "## #{index}:\n#{item[:code]}#=> #{inspect item[:result]}"
    end
    nil
  end

  @doc """
  Retrieves Nth query's value from the history
  """
  def v(n) when n < 0 do
    history_length = length(Process.get(:__history__))
    v(history_length + n + 1)
  end
  def v(n) do
    history = List.reverse(Process.get(:__history__))
    item = :lists.nth(n, history)
    item[:result]
  end
end