Removed the last shared global, added the program queue

The program queue allows inputs to change the currently running program
at the start of the next generated loop without the need for global
variables shared between threads.