Fix comparisons functions, likely fixes issue #8596.