fixed possible npe in getTemplate
intialize the cache in a static code block