Automatically detect groups inside broken chapter groups

Producing broken output when we knew it's broken didn't make much sense.
Merge adjacent groups with similar shift after correcting chapter groups