Some more fixes in the search algorithm