even more type checking
fix some crashes during typechecking