Ensure events are ordered predictably
Fix bug in maxDate when end_date is null