cleaned up old k-NN code