Generators and templates refactored