some fixes to simulate.js