Bug fixes and Suspend/Resume

1. Fixed loop bug
2. Fixed crash arising from not having files to download
3. Added code to (hopefully) improve suspend/resume event handling.
4.