Merged with upstream change for templates