Port PR #5457 to master