Fix variables access in templates