speed up levenshtein distance

This speeds up levenshtein distance calculation by about 1.6x
Merge pull request #809 from tenderlove/faster_levenshtein

Speed up levenshtein distance