Reduce memory footprint for knn and use h5py instead of pickle.