Starting some cleanup (bracketless if statements over multiple lines is dangerous).
Finished cleanup, consistent code style, fixed warnings.