Fix Bug 965501, use flex for moar header awesomeness

@erikrose r? A little welcome home present ;) And look at all the code we can remove. Flex FTW!