cleaned code a bit & tweaked sockets