Fix some bugs of generating files.