Allow a default template to be specified. Fixes and improvements.