Scripts: prevent some runtime errors