Added instanceof object type check to equals methods.