Added simulation argument, and reorganized.