Better fix for socket timeout bug