Fix bug in recursive simulation