Minor cleanup and logging for the search method.