Finished first draft of type inference, untested.
The type inference algo converges now.