Minor cleanups, and test fixes