REF: Split threads and socket implementations