Matching algorithm improvements