Revert "Simplied fuzzy matching code"

This reverts commit 64d6a32da52234d93240b03a95a5238c34417aeb.