save and load for distances and indices