This allows for metadata to be associated with the template and a simplification of the template init logic.
Fixes #656