Major Bugfix

Fixed a major bug where large amounts of data would not be sent
correctly; this was due to the fact that we were using a 16 bit integer
to transmit the size of a packet, and we also weren't checking to see if
the entire packet had been sent.