Assorted cleanups

Branch to collect assorted fixes I stumbled across.