fixed two edge-case bugs in custom search

also removed some commented out code
added finding near matches with only substitutions

also added a super-generic find_near_matches() utility function