Merge pull request #5830 from senivam/40_merge

merge of the actual 3.1 into the 4.0