Modify comments and formatting, and move header spec logic into one method