Restructured template generation, started security