refactoring.
socket client/server + fixes