Fixed duplicate declaration errors when using the same templates or files
with multiple instances.