Improve groupcount handling (bug #2529) thanks!