Use wfScript() instead of globals in a few places