Fixed typo.
Refactored socket object creation a bit.