added caching to metrics and fixed template