Merge branch 'rs/avoid-overflow-in-midpoint-computation' into maint