bugfixes in resampling routines