Various minor refactorings.