Some internal refactoring.