Clean up main function