Cleaned up networking code