Clean up this code a bit.

Prep for #555.