Fix off-by-one errors in code to find depth of stack.

XXX The code is still widely inaccurate, but most (all?) of the time
it's an overestimate.
2 files changed