Improved timeout handling