Fix race condition in initialising sim.js