Improved template management