Cleaning up the code (mostly in simulation module)