fixed some bugs when viewer is disconnected