Improve networking code, move auth logging