You need to start telling us those things at the beginning.

If you change all the Start/Stop/Flag variables to arrays, it should work with multiple programs.
.