Fix bug in caching system
Improved template lua-ability