Added more templates and some refactoring