Heavy internal refactoring toward use of an internal type-system.