Fix submitted output in verbatim mode.
Improve detection of IPython console sessions.