Refactor some search stuff

I like how clear this is.