add configuration flag useWebSocket, code cleanup