Made some optimizations in group search.