Implement type code

@certik Let me know what you think about this PR, so I can go ahead and implement it for all classes if we are going through with this approach