Moved header generation code into own methods.