Simplified template tags logic and nesting levels.