Added caching for templates