And some more refactoring