Reorganizing template engine structure