I can help with the Loop part
For example, if you have the following:
Loop 0 to %Names.Count - 1% increment of 1
'Do something
End Loop
You could actually have an environment variable that tells the system which loop you are on, so if you cancel in the middle of a loop, you can come back to it:
Get Environment Variable %EV_LoopIndex% (should be set to 0 before your first run)
Loop starting at %EV_LoopIndex% to %Names.Count - 1%
Set Environment Variable %EV_LoopIndex% to %LoopIndex% 'set it to the current loop number
'Do something
End Loop
Now, if your loop fails, and you have to reset the program, when it comes to the loop, it will pick up where it left off. Instead of starting at LoopIndex 0, it is going to start at %EV_LoopIndex%.
Good luck!