Changed variable substitution in templates
New code for compile_template