Added template option and fixed a caching key issue.