Bugfixes in the program factory. Tested several different programs.