Some bugs in simulation fixed