Fix an off-by-one error calculating the minimum close depth.

We were subtracting the minimum depth below 0, which
since these numbers are NSUIntegers was making it
overflow.
Dodge weird bug by making totalClosedRange an NSValue.

Using totalClosedRange as a block NSRange variable
resulted in wonkiness trying to assign its location attribute,
giving bizarre results for the range. Instead we now wrap it
in an NSValue so we can use it unharmed.
Fix an off-by-one error when checking for range contiguousness while closing.