Improved template rendering