More refactoring and cleanups WIP