Fixed tag and var precedence when inheriting from templates that inherit from templates