loading templates in the cache + some minor improvements