Replace locals() and pass only parameters that the templates need
Merge remote-tracking branch 'origin/fix_locals'