A little cleanup.

Shorten long lines, extract a function, and add comments.