Misc refactorings.