Add null checks to EnsureDates