A LOT of fixes
Edit distance tested