Improve timeout detection