Fixed errors in the calculation of timeouts.