Refactor Cactus Graph for batch inference