Add pointer tracking to catch cycles (Addressing #1)