Added more template creation logic and changed template accordingly.