Fixes to new search algorithm