Use ArrayStack for tracking accumulation in tailrec folding

Improves performance by several orders of magnitude