clean up style to make the repository consistent

Updating lots of little inconsistencies, and writing more clear comments for lots of the methods.