Miscellaneous refactoring.