Optimize #291, fixing #290 when creating groups.