Use more assert_class_string and less instanceof.