Various socket fixes