Add finer treatment of first and last ramps with regards to perturbations