Typechecker improvements
Fixes #32