Improvements on templates cache