Refactor of sockets and groups