Restructured search module.
Searching refactored, not quite DRY.