Fix a bunch of bugs related to resampling