MTP reliability fixes

After this commit series I can transfer 600 MB files both ways, and copy hundreds of files from the device. (Copying lots of files to the device didn't work due to problems in my host software; I can test it better tomorrow)