More refactoring and organization