Some bits of refactoring