Cleanups, more refactoring