Implemented most of the remainder of type decision.