Fixed crashing bug with getNeighborsND (wrapAround=true case)