Fix some wrong instance checks in equals().