Improved template system