Backport #18442 and #18871 to 2014.1

Backport #18442 and #18871 to 2014.1