Fix bug in removing connections