Saner formatting and whitespace.

Remove unnecessary whitespace.
Stop using PHP's alternative if and while syntax.
Much more consistent indentation.
Generally improved formatting.
There's still work to do I;m sure, but this is a step in the right direction.