Refactor some search stuff

Yeah, good call.