Dv/template refactor