templates and views optimizations