Refactor generation script