Improve search refinements, make refinements pluggable (issue #547)