Just an update. Currently there is a stack overflow caused by erroneous cycles in the NFA. Cycles should not exist in the branch pointers, but in the loopback pointers. The stack overflow arises from attempting to gather leaves from a root node in the NFA.