Add templates and some functions