Misc. cleanups

Wow, that looks like a serious bug.  Nice catch.