Cleanup code which loops over search results.