made fixes to header handling