Fixing variable scoping issue to properly clear current_group.