more template work, and the functions to support them.