I forgot that the inner scope isn't necessarily exited when updating
upperWasValid. (Additional iterations overwrote the result before the
upper level could read it.) This is fixed now. Inner level only adds to
the value, upper level resets it to 0 before going down.