Fixed a bug where the end date would be incorrectly calculated.