Fix comparator null bug.
Improve comparator null check.