Added KNN method and code cleaup.