Improve equality check anticipating edge cases.