Fixed bugs in connection timeout implementation