bug fixes

fix problems with improper download synchrornization
ensure the last chunk is downloaded before the middle