Implemented printing, extracted REPL functionality