StackFrames calculation has been refactored to improve performance and simplify code