template() optimised - now caches instead of reading from file each time. Significant speed up.