Fixed renaming long template names

Fixes #2052