Fix to properly prioritize templates.