some more refactoring & cleanup