JK: Added some handling for network connection issues.