Improved disconnect handling