fix some issues in script generator