Cleaning up neighbors function.