Fix stack depth computation