Readd accidentally deleted template code

This shouldn't be deleted in this branch.