Some more code refactoring.