Fixing bugs with primal calculation and resampling