Different distance handling based on matrices. We can have indices and distances at the same time