Revised MainLoop to properly computer the number of bytes to move A5