Cleanded up K nearest neighbour code and added some comments