WIP: improved template performance