Checking reference to speed-up equality check, fixes #1