Many changes to networking, added a few tests, fixed many bugs.