Fix a segfault, and add script-level support for some more commands.