Heavily refactor search to be more performant.