Refactoring.

Partially applied guidelines from STYLE.txt, some might still not
be complete though.