Merge header parsing into class

Move the header parsing functionality into a dedicated class.