Networking-related improvements

Refactored a bunch of OkHttp/Okio-related things. Also fixed the bug where the upload process would get stuck at 99% due to the buffer not being flushed properly.