Refactored type definition code.