Cleaned a bit some code.
Changed a sleep into a wait socket.