This was mostly done automatically and then visually inspected for obvious errors. All //-style comments should have a 2-space separation from the code, and 1 space after the comment sign.
Indenting by spaces and alignment by spaces, as well as trailing whitespace on non-empty lines.