Loads of comments and a few tweaks. Should make for better legibility.