Template refactoring close #273