Refactored type.coffee