Reworked templates backend