Fixed regressions in distribution and undistribution routines