Formatting updates to improve readability.

Most changes involve returning early to reduce nesting.