Clean up logging and add command line flags