Made normalizeDuration more generic.