Fix undefined variable error in JS
Fix bug with user-specified Tpl chunks