Remaining part of #2004.
Remaining part of #2004.