Fixed a bug that raised an exception when modifying a template. Also changed how templates were addressed to consider a template when "name" is set rather than "register=0".