Janitor patches

A bunch of cleanup patches.