pipeline: rework optimization pattern for header generation