Improved template file partitioning