Improve the implementation of some of the type checking predicates