Issue #5: fix some bugs that prevented thread halting of download