Fixed a number of bugs. KNN still not working.