changed socket close to end, added some debugging and fixed the way the socketList is managed