Improved and debugged resample_..., added a `clobber` option.