Tweaks to socket API