Finish refactor of search.