Factor out some methods in the header generation