I'm kinda thinking that there should be a metadata item containing the entire original header as a string.  Then when writing out the header can be first created from the original header, then updated as necessary. Might be kind of tricky though....