Improved code formatting, and commenting

Also fixed several issues with sections