Added tests, which cleaned up the app substantially.