Fixed memory errors recently added to Socket