Small fixes to match checking, working on the search algorithm