Port changes from the "pdd-stdev" branch to 0.6.