Improve timeout handling