fix code generate bugs