Store headers internally as arrays and refactor

This lets us do more magical stuff in other places, since we might need
case-insensitive dictionaries elsewhere. The internal use of arrays
breaks one test at the moment, this will need to be fixed.