Removed commented-out bits of code that are clearly not going to be used
Standardised indenting of new code
Added some more comments, moved a few variable declarations
Merge resolution