Complete unification of thread_loop/peerd_loop