Fixes for main_script() for running from the command line.