Fix template nesting