Refactor (and fix) search term separation