More guards around script functions