Backport the fixes for Bug#4114 to the 1.3.5 branch.