Added cleanup socket code.