Better handling of ping timeouts and failed connections