More robust timeout handling