Lots of cleanup for logging and more p2p stuff