Merge branch 'hotfix/4631'

Close #4631
Resolved merge conflicts from commit a8eda2d
Resolved merge conflicts from commit 83ba3cf
Merge branch 'hotfix/4640' into develop

Forward port #4640