Fixed issue with agent disconnection