Fixed a disconnect handling bug