Some internal refactorings.