ENH: use heapq to select the best match
TEST: fix precision
TEST: fix bad subs