Template engine improvements