Fix a few type checking bugs.