Fixed NPE when comparing dates