improved connection clearing