Sim refactor

Re-factor of SIM code