Added end() to socket
Code clean up