Improved check for connectivity.