Improved handling of timeout, adding a logging call.