more refactoring, and the start of a CLI app