Fix bug in which templates can only be used once per request