Several fixes to file transfer