Refactored config and template generation to separate script