Clean up code to calculate the timeout.