Improved handling of timeout