Revised simulation functions, added examples.