Updates to simulation code, added some accessory functions
updates to simulation code