Make the header length check more stringent.
Fix missing import.