Various small refactoring changes