Modified to speed up transfer and also to send progress update
periodically. Still need to clean up some parts