Fixed bug with wrong end date being used