Added KNN method and code cleanup