Remaining part of #2176.
Remaining part of #2176.