many improvements to type checking
Many improvements to type checking