Refactor unitdef to take types
Conversion for dimension type
Cleanup