Fix bug in TS neighbor search