Refactored type system to be more object oriented.