Rewrote header generation.

In preparation for auto ids.