Various fixes to type checking (experimental parser)