bug fixes and new use of templateCache