Fix casts in header parsing