Implement header demotion (via #891)

Fixes #891.

Was in master for about two minutes, but then I decided to make this into a pull request.

So, waiting for review.