Backport rred patches from my own sid branch to the 0.7.25 branch