Finish implementation of the type inference engine.