Some templating improvements