Replaced get_class() calls with instanceof operators

This PR replaces get_class() calls with instanceof operators.

Fixes #570.
Possibly a valid point. I would suggest you create a ticket for that and limit this PR to turning get_class into instanceof, i.e. undo these changes.