Fixed instance checking to allow for inheritance.