Fixed bugs in header generation