Further work on the search provider. Needs tidying up.