KNN kernel cleanup.