Code

Clean up a bit. Clarify several variable names. Add a lot of comments.