Solve array index out of bounds probem in nearest_search.
Merge pull request #42 from rolftimmermans/array-oob

Solve array index out of bounds probem in nearest_search.