Cleanup and test fixes