Moved socket code into a module
Cleanup of use statements