Improved SafeCompare.