Formatting

Adds a lot of comments and some minor formatting