Refactoring and a command-line test app.