More changes to main function