Takes chunk id == 0 into account during grouping
Merge pull request #3964 from yurydelendik/issue-3962

Fixes chunks grouping