Patches for 3.1.3

I'll push to my patches branch from now on. I think this one pull request will be able to capture them all.