Simplify the way inheritance is checked.

Thanks @nvloff!