Large refactoring.