Fix for NPE when checking for connection.