Refactor search engine code.