Faster edit distance algorithm

The edit distance algorithm made some pages unacceptably slow, so this version has a faster implementation.