Apply gri's suggestions for cleanup and reorg.
Correct comment to match actual behavior.