Improved the detection of invalid headers (or lack of necessary headers).