Refactor this into a testable app.

It's about time.