Adds system template variables and adapts the code