Search refactoring pass. Touches on #231