Check connectivity before dialogs are displayed
Added ProtocolException
Refactoring