More cleanups & refactoring