Pull request #5430 with merge conflicts resolved

See #5430.