Refactor generation script.

This makes it easier to handle multiple files.
More refactoring to handle multiple structs.