Removed unnecessary global creation
Cleaner treatment of global input state
Simulation copies globals to locals for inner loops