Replaced socket class, more solid also for 2to3. Logging slightly changed