Refactored to prepare for switching search engines