Some minor cleaning up.
Some refactoring for our CLI version (#199).