Fixed recently introduced bug which caused out-of-range access
Styling
Integrated new resample algorithm