Improved handling of headers