More Comments and Some Refactoring

Going through app.py again to make it more readable.

I realized that I had already forgotten how everything worked since I wrote it
2 weeks ago, so I went through and documented everything javadoc-style.

It's not 100% finished yet; I'll come back and comment more before next week.