Refactored header parsing.