Fix template generation