fix disconnected flag, bugfixes