Improved disconnect handling.