Fix #1652.
Fix conflict between changes in #1641 and #1642
Merge remote-tracking branch 'origin/master' into issue1647