Fix polymorphic class checking.