fixed a bug causing neighbors to be removed incorrectly.