Fix a bug where we could overflow TIMEOUT_MAX causing the timeout to be set to 1