Moved the code for processing the command line flags out to a separate function so we can get a cleaner main module.