#1718 rebased for patch

#1718