Refactors template generator