Some general refactoring.