fix some issues of generated main function