Fix forward port, improved.

This shows the actual changes which will go in, at the cost (hopefully bearable) one extra merge commit.