Fixed nested template issues.