Some small refactorings and cleanups.