Add a lot of simulation logic

Still testing the sim logic, not complete yet.