Improve generation performance

- improve generation speed
- resolve warning