Added a better fix for ticket #13037 to the 2.1.X branch, previous fix was done in master branch