Refactor type implementation.
Merge pull request #1840 from AndrejMitrovic/RefactorType

Refactor type implementation