Added code to detect loss of data connection.