Ensure whois sockets are closed.
Removed legacy code as per #27
Reduced duplicated code