Cleaned up the main loop.
I need to work out some math before proceeding. I'll do it in these documents.