Fixed some problems in simulation