Factor out util functions.
Strip trailing whitespace.
Add REPL interfaces.