Remove more grouping logic from the template

Fix #1
Retab template