More refactoring & cleanup