fixed some issues with restarting socket on error