Replaced get_class() calls with instanceof operators

This PR replaces get_class() calls with instanceof operators.

Fixes #570.
Agreed, I'll do that as a separate PR and fix this for the time being.