Presorting of neighbors added, needed for suboptimal planning to work well