Fix #310.
MDL-48246.
Fix #397.
Fix #396.
Merge remote-tracking branch 'upstream/master'