Fix crash when using the template tool