Added some logging support, cleaned up networking a bit.