Bugfix for duration calculation

End time is now converted to int before delay is added, so the calculated duration is correct in case delay > 0