Moving the counters writing out of the innermost store template, as it
does not depend on the DM.