Refactor some code for template management (issue #47)
Refactor some code for warnings (issue #47)