fix: double free in simulation, and another bug in simulation