Refactoring and cleanup...