Various refactorings