Fix header detection

Take into account formatting inconsistencies.