refactor application, making some of the process easier to unit test.

Signed-off-by: crynobone <crynobone@gmail.com>