Replaced get_class() calls with instanceof operators

This PR replaces get_class() calls with instanceof operators.

Fixes #570.
What do you think of marking these methods as abstract? Actually the whole base class should really be marked abstract since it shouldn't be instantiated directly anyway...