Fix returning incorrect edit distances