Moving REPL code to its own module in preparation for better testing.