Improved connection handling.