By factoring this code out, we make it easier to convert to NSE. http://seclists.org/nmap-dev/2013/q4/255