Only define the main function if run as a script.