Various small refactorings