Fix rich compare with a guard for object types