Storing stack.length for performance