Some socket bug fixes