Fixed use of global variable in main.