Fix some typechecker bugs