Misc cleanup.

This commit contains various code cleanup such as comment fixes and
function ordering consistency.