cleanups and test fixes