improved connection cleanup