Refactor by extracting DistanceMetric as interface

More abstraction, hurrah!