Clean up supporting code

It may be easier to step through the commits than to look at the changes all at once.