and some more refactoring