Improve performancy by caching rendered snippet content

* cached rendered snippet content
* add cache invalidation logic: whenever a snippet pointer, snippet, variable or variable value changes, invalidate the cache
* also includes some minor coding style improvements