Serious refactoring.