Fix variables access in templates.

Fix some variables access in templates.