Optimal match distance

Under construction!