Improved REPL and some code cleanups.