corrections to resample functions to protect in case of non exact division into new bin width