Fix incorrect variable names in the updated instrumentation code.
Fix off-by-one in the stack usage calculation, prevent overflow.