Some changes to try to avoid errors when running past end of search results