Factor out some process and file functions.
Clean up and decouple some code in the CLI module.