Some refactoring in the way results are groupped and how the find query
is constructed