Fixed the resample and backward functions