TerminateSimulation() now properly cleans up semaphore set by allowing all threads to unwait and terminate gracefully before freeing the set, semaphore ids renumbered to reduce the size of the sempahore set, comments added