Simplify header substitution a bit more, reduce dupe code.