Fix off-by-one around inclusive vs exclusive ranges