more refactoring to make the socket architecture make more sense