diff --git a/.tarball-version b/.tarball-version
index fc73074..fd6d73e 100644
--- a/.tarball-version
+++ b/.tarball-version
@@ -1 +1 @@
-0.94
+0.95
diff --git a/AUTHORS b/AUTHORS
index d4c2a1f..a2025ce 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -7,7 +7,7 @@
   Bug reports and feature requests should be sent as described in
   the README file.
 
-  Thanks to everyone who has provided feedback on mtr.  
+  Thanks to everyone who has provided feedback on mtr.
 
   Thanks especially to those of you who have sent code:
   (Reverse alphabetical order, and sometimes I just add people at
@@ -30,11 +30,11 @@
         Davin Milun
         Josh Martin <jmartin@columbiaservices.net>
         Alexander V. Lukyanov <lav@yars.free.net>
-        Charles Levert <charles@comm.polymtl.ca> 
+        Charles Levert <charles@comm.polymtl.ca>
         Bertrand Leconte <B.Leconte@mail.dotcom.fr>
         Anand Kumria
         Olav Kvittem <Olav.Kvittem@uninett.no>
-        Adam Kramer <l3zqc@qcunix1.acc.qc.edu> 
+        Adam Kramer <l3zqc@qcunix1.acc.qc.edu>
         Philip Kizer <pckizer@nostrum.com>
         Simon Kirby
         Sami Kerola <kerolasa@iki.fi>
@@ -49,7 +49,7 @@
         Travis Cross <tc@traviscross.com>
         Brian Casey <bcasey@imagiware.com>
         Andrew Brown <atatat@atatdot.net>
-        Bill Bogstad <bogstad@pobox.com> 
+        Bill Bogstad <bogstad@pobox.com>
         Marc Bejarano <marc.bejarano@openwave.com>
         Moritz Barsnick <barsnick@gmx.net>
         Thomas Klausner <wiz@NetBSD.org>
@@ -63,7 +63,7 @@
 
         and anyone who has slipped through the cracks of my mail file.
 
-Authors: If you want your Email mentioned here, send it to me. 
-         If you don't want your Email mentioned here, tell me.  
+Authors: If you want your Email mentioned here, send it to me.
+         If you don't want your Email mentioned here, tell me.
 
         -- REW
diff --git a/FORMATS b/FORMATS
index d0e05ff..cae643d 100644
--- a/FORMATS
+++ b/FORMATS
@@ -6,7 +6,7 @@ gui-library with a setuid program.
 
 The split format is:
 
-<pos> <host> <loss%> <rcvd pckts> <sent pckts> <best> <avg> <worst> 
+<pos> <host> <loss%> <rcvd pckts> <sent pckts> <best> <avg> <worst>
 
 
 The "raw" format is:
@@ -22,7 +22,7 @@ x <pos> <seqnum>
 pingline:
 p <pos> <pingtime (ms)> <seqnum>
 
-dnsline: 
+dnsline:
 d <pos> <hostname>
 
 timestampline:
@@ -37,7 +37,7 @@ ICMP timestamping first. :-)
 
 Someone suggested to put the following text here. As to context: Some
 people are wondering why mtr sometimes reports hosts beyond the
-destination host. 
+destination host.
 
 
 The FINAL host will occasionally be mentioned at position n, n+1, n+2
@@ -102,4 +102,3 @@ h 15 152.63.50.89
 h 16 152.179.99.218
 h 17 152.179.99.218
 h 18 152.179.99.218
-
diff --git a/Makefile.am b/Makefile.am
index 7719be1..3737a93 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -40,7 +40,7 @@ $(PATHFILES): Makefile
 dist_man_MANS = mtr.8 mtr-packet.8
 PATHFILES += man/mtr.8 man/mtr-packet.8
 
-install-exec-hook: 
+install-exec-hook:
 	`setcap cap_net_raw+ep $(DESTDIR)$(sbindir)/mtr-packet` \
 	|| chmod u+s $(DESTDIR)$(sbindir)/mtr-packet
 
@@ -172,4 +172,3 @@ endif
 
 dist-hook:
 	$(AM_V_GEN)echo $(VERSION) > $(distdir)/.tarball-version
-
diff --git a/NEWS b/NEWS
index 922036e..ddbac03 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,68 @@ The new release script will do a "git shortlog" to add
 the commit messages here. 
 
 #NEW_STUFF_HERE this is a tag my script looks for. 
+V0.95
+   Aaron Lipinski (27):
+         move net_send_batch call to its caller
+         addr -> hostent for consistency
+         re-init source too
+         additional call from net_reopen
+         refactor - group local, remote inits
+         reset ctl address family at net_reopen
+         accept only value used in structure
+         tell dns process if we want 4 or 6
+         resolve ipv6 only if we have ipv6
+         remove wrapper only function
+         init structures correctly wired up
+         prepare host with h_addr_list
+         remove temporaries
+         extract convert_addrinfo_to_hostent function
+         move conversion call to caller
+         use addrinfo
+         remove conversion function
+         switch gui to addrinfo
+         export DEFAULT_AF
+         reset addr family before searching again
+         freeaddrinfo
+         export get_hostent_from_name
+         make Hostname as const
+         rename function
+         dont show json option if not available
+   
+   Egor Panov (1):
+         Updated Readme
+   
+   R.E. Wolff (2):
+         Slight cleanup, but no fix for code that came up in a bugreport.
+         increased max length suggested by YVS2014
+   
+   Roger Wolff (12):
+   
+   Rogier Wolff (2):
+         Code formatting for Zenithal pull
+         added clarification to readme suggested by Zenithal
+   
+   Sergei Trofimovich (1):
+         ui/curses: always use "%s"-style format for printf()-style functions
+   
+   Vincent Bernat (3):
+         ui: don't cast to void* when calling display_rawhost()
+         net: fix MPLS display for curses and report
+         report: fix display of MPLS labels when using --report
+   
+   Zenithal (1):
+         Add display of destination with resolved addr under curses mode
+   
+   a1346054 (5):
+         fix wrong bash completion flag
+         fix shellcheck warnings
+         unify codestyle
+         fix spelling
+         trim trailing whitespace
+   
+   gaamox@tutanota.com (1):
+         Report secondary servers when CSV + wide report is enabled
+   
 V0.94
    Aaron Lipinski (10):
          gtk_menu_append -> gtk_menu_shell_append
diff --git a/README.md b/README.md
index 9db7b62..9e4ebbb 100644
--- a/README.md
+++ b/README.md
@@ -22,6 +22,10 @@ simple as:
 
 	./configure && make
 
+Please note that this refers to the tarballs from
+ https://www.bitwizard.nl/mtr/files/
+and not the tarballs that github can produce.
+
 (in the past, there was a Makefile in the distribution that did
 the `./configure` for you and then ran make again with the generated
 Makefile, but this has suffered some bitrot. It didn't work well
@@ -71,10 +75,10 @@ BUILDING FOR WINDOWS
 
 Building for Windows requires Cygwin.  To obtain Cygwin, see
 https://cygwin.com/install.html.
-Next, re-run cygwin's `setup-x86.exe` (or `setup-x86_64.exe` if you're using 64bit cygwin) with the following arguments,  
+Next, re-run cygwin's `setup-x86.exe` (or `setup-x86_64.exe` if you're using 64bit cygwin) with the following arguments,
 which will install the packages required for building:
 
-        setup-x86.exe --package-manager --wait --packages automake,pkg-config,make,gcc-core,libncurses-devel
+        setup-x86.exe --package-manager --wait --packages automake,pkg-config,make,gcc-core,libncurses-devel,libjansson-devel
 
 Build as under Unix:
 
@@ -106,4 +110,3 @@ when the server was upgraded, the mailing list died.)
 
 
 REW
-
diff --git a/SECURITY b/SECURITY
index 82c697c..3dae7e5 100644
--- a/SECURITY
+++ b/SECURITY
@@ -35,7 +35,7 @@ minimal.
 3. Make mtr-packet a setuid-root binary.
 
 The mtr-packet binary can be made setuid-root, which is what "make install"
-does by default.
+does only if using setcap (above) fails.  Using setcap is tried first.
 
 When mtr-packet is installed as suid-root, some concern over security is
 justified.  mtr-packet does the following two things after it is launched:
diff --git a/TODO b/TODO
index ed8950f..95481c5 100644
--- a/TODO
+++ b/TODO
@@ -1,5 +1,4 @@
-
-Hi everyone, 
+Hi everyone,
 
 This is the "todo" file for mtr. I just realized that some people
 might think that this is all in MY queue to implement. That is not
@@ -16,13 +15,15 @@ implement something on this list. That way we get the design of
 these things the way I like them. This should result in a better
 maintainable mtr.
 
-Oh, Feel free to provide suggestions for this list. 
+Oh, Feel free to provide suggestions for this list.
 
 
 -- REW
 
 ----------------------------------------------------------------------
 
+- cleanup
+  - cleanup warnings that the newer GCC produces.
 
 - Stuff to implement:
 
@@ -32,16 +33,16 @@ Oh, Feel free to provide suggestions for this list.
     mtr.
 
   - Request timestamping at the remote site.
-       Andreas Fasbender has an algorithm that will allow us to 
+       Andreas Fasbender has an algorithm that will allow us to
        convert these measurements into one-way measurements, not just
        round-trip.
 
-  - allow "keyboard navigation" in the GTK version. 
+  - allow "keyboard navigation" in the GTK version.
 
   - Keep all packets and make the "best" and "worst" columns show the
     xx-th percentile....
 
-  - Being able to expand the "column width" of the hosts listed would 
+  - Being able to expand the "column width" of the hosts listed would
     be nice, too.
 
   - Display per host stats when multiple servers respond at a particular
@@ -50,32 +51,32 @@ Oh, Feel free to provide suggestions for this list.
 
 - Bugs to fix?
 
-  - Do something useful if host couldn't be resolved. 
-       -- Done. 
+  - Do something useful if host couldn't be resolved.
+       -- Done.
 
   - Revert to curses mode even if DISPLAY is set, but a problem
     prevents us from running in X11 mode.
        -->  The problem is that gtk_init simply calls exit for us if
-            it finds a problem. Tricky! Suggestions welcome. 
+            it finds a problem. Tricky! Suggestions welcome.
        --> Call "gtk_check_init" when available. (i.e. new enough
            (1.2?) GTK version).
 
 - Nice to have:
 
-  - stop sending packets when a new host is getting entered. 
+  - stop sending packets when a new host is getting entered.
 
   - Show state ("looking up host") while doing the DNS lookup for a new
     host.
 
   - to have a choice of icmp, tcp, and udp pings. -- Matt Martini
 
-  - Autoconf 2.13 has a neat function that can be used to find the 
-    res_init function: 
+  - Autoconf 2.13 has a neat function that can be used to find the
+    res_init function:
 
 	   AC_SEARCH_LIBS(res_init, bind resolv, ,
 	      AC_MSG_ERROR(No resolver library found))
 
-    At the moment (march 1999) autoconf 2.13 is still too new to require 
+    At the moment (march 1999) autoconf 2.13 is still too new to require
     everyone to upgrade. About a year from now we can put this in....
 
   - Implement rfc2317 mechanism to do reverse lookups for networks that
@@ -102,11 +103,11 @@ Oh, Feel free to provide suggestions for this list.
 
 Things that shouldn't be on the TODO list because they're done. ;-)
 
-  - Allow a toggle between hostname/IP number display. (for example a 
+  - Allow a toggle between hostname/IP number display. (for example a
     click on the hostname could revert to ip number display in gtk version.
     curses: "n" key toggles hostnames/ipnumbers?)
 
-  - Allow mtr to also send larger packets. 
+  - Allow mtr to also send larger packets.
        This will enable us to get a feel for the speed of the links
        we're traversing. (Van Jacobson was working on this His tool
        was slow, mtr will rock with this feature.... :-)
@@ -118,9 +119,8 @@ Things that shouldn't be on the TODO list because they're done. ;-)
     It should not probe more than 10 unknown hosts, but the counter need
     not be reset at the start of the "round". This way if you probe
     slowly (relative to the RTT time to the end host), it can probe
-    all hosts in the first "round". 
+    all hosts in the first "round".
        -- DONE.
 
   - Read environment variable "MTR_DEFAULTS" as a commandline before
     parsing the commandline.  -- DONE. (ok it's MTR_OPTIONS.)
-
diff --git a/bash-completion/mtr b/bash-completion/mtr
index 4d9d5dd..63b153b 100644
--- a/bash-completion/mtr
+++ b/bash-completion/mtr
@@ -8,43 +8,43 @@ _mtr_module()
     '-F'|'--filename')
       local IFS=$'\n'
       compopt -o filenames
-      COMPREPLY=( $(compgen -f -- $cur) )
+      COMPREPLY=( $(compgen -f -- "$cur") )
       return 0
       ;;
     '-a'|'--address')
-      COMPREPLY=( $(compgen -W "ADDRESS" -- $cur) )
+      COMPREPLY=( $(compgen -W "ADDRESS" -- "$cur") )
       return 0
       ;;
-    '-f'|'--first-ttl'|'-m'|'--max-ttl'|'-m'|'--max-unknown'|'-B'|'--bitpattern'|'-Q'|'--tos'|'-c'|'--report-cycles')
-      COMPREPLY=( $(compgen -W "NUMBER" -- $cur) )
+    '-f'|'--first-ttl'|'-m'|'--max-ttl'|'-U'|'--max-unknown'|'-B'|'--bitpattern'|'-Q'|'--tos'|'-c'|'--report-cycles')
+      COMPREPLY=( $(compgen -W "NUMBER" -- "$cur") )
       return 0
       ;;
     '-P'|'--port'|'-L'|'--localport')
-      COMPREPLY=( $(compgen -W "PORT" -- $cur) )
+      COMPREPLY=( $(compgen -W "PORT" -- "$cur") )
       return 0
       ;;
     '-s'|'--psize')
-      COMPREPLY=( $(compgen -W "SIZE" -- $cur) )
+      COMPREPLY=( $(compgen -W "SIZE" -- "$cur") )
       return 0
       ;;
     '-i'|'--interval'|'-G'|'--gracetime'|'-Z'|'--timeout')
-      COMPREPLY=( $(compgen -W "SECONDS" -- $cur) )
+      COMPREPLY=( $(compgen -W "SECONDS" -- "$cur") )
       return 0
       ;;
     '-M'|'--mark')
-      COMPREPLY=( $(compgen -W "MARK" -- $cur) )
+      COMPREPLY=( $(compgen -W "MARK" -- "$cur") )
       return 0
       ;;
     '--displaymode')
-      COMPREPLY=( $(compgen -W "{0..2}" -- $cur) )
+      COMPREPLY=( $(compgen -W "{0..2}" -- "$cur") )
       return 0
       ;;
     '-y'|'--ipinfo')
-      COMPREPLY=( $(compgen -W "{0..4}" -- $cur) )
+      COMPREPLY=( $(compgen -W "{0..4}" -- "$cur") )
       return 0
       ;;
     '-o'|'--order')
-      COMPREPLY=( $(compgen -W "LDRSNBAWVGJMXI" -- $cur) )
+      COMPREPLY=( $(compgen -W "LDRSNBAWVGJMXI" -- "$cur") )
       return 0
       ;;
   esac
@@ -58,11 +58,11 @@ _mtr_module()
         --curses --displaymode --gtk --no-dns --show-ips --order --ipinfo
         --aslookup --help --version
       '
-      COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+      COMPREPLY=( $(compgen -W "${OPTS[*]}" -- "$cur") )
       return 0
       ;;
   esac
-  COMPREPLY=( $(compgen -W "ip_address hostname" -- $cur) )
+  COMPREPLY=( $(compgen -W "ip_address hostname" -- "$cur") )
   return 0
 }
 complete -F _mtr_module mtr
diff --git a/build-aux/mangen.sh b/build-aux/mangen.sh
index 6ce777e..cdc2a01 100755
--- a/build-aux/mangen.sh
+++ b/build-aux/mangen.sh
@@ -7,7 +7,7 @@
 #
 
 if [ $# -lt 3 ]; then
-    echo Usage: mangen.sh VERSION IN OUT
+    echo "Usage: mangen.sh VERSION IN OUT"
     exit 1
 fi
 
@@ -20,10 +20,10 @@ OUT=$3
 #  URL completely disappear from man pages.  We need to strip
 #  those codes out when building for MacOS
 #
-if [ $(uname -s) = "Darwin" ]; then
+if [ "$(uname -s)" = "Darwin" ]; then
    RMURUE='-e s/\.UR.//g -e s/\.UE//g'
 else
    RMURUE=""
 fi
 
-sed -e "s|@VERSION[@]|$VERSION|g" $RMURUE $IN >$OUT
+sed -e "s|@VERSION[@]|$VERSION|g" $RMURUE "$IN" >"$OUT"
diff --git a/man/mtr.8.in b/man/mtr.8.in
index 9d13535..80c4790 100644
--- a/man/mtr.8.in
+++ b/man/mtr.8.in
@@ -114,38 +114,38 @@ mtr \- a network diagnostic tool
 ]
 .I HOSTNAME
 .SH DESCRIPTION
-.B mtr 
-combines the functionality of the 
+.B mtr
+combines the functionality of the
 .B traceroute
-and 
+and
 .B ping
 programs in a single network diagnostic tool.
 .PP
-As 
-.B mtr 
-starts, it investigates the network connection between the host 
+As
 .B mtr
-runs on and 
+starts, it investigates the network connection between the host
+.B mtr
+runs on and
 .BR HOSTNAME
 by sending packets with purposely low TTLs.  It continues to send
 packets with low TTL, noting the response time of the intervening
-routers.  This allows 
-.B mtr 
+routers.  This allows
+.B mtr
 to print the response percentage and response times of the internet
-route to 
-.BR HOSTNAME . 
+route to
+.BR HOSTNAME .
 A sudden increase in packet loss or response time is often an indication
-of a bad (or simply overloaded) link. 
+of a bad (or simply overloaded) link.
 .PP
 The results are usually reported as round-trip-response times in milliseconds
-and the percentage of packet loss. 
+and the percentage of packet loss.
 .SH OPTIONS
 .TP
 .B \-h\fR, \fB\-\-help
 Print the summary of command line argument options.
 .TP
 .B \-v\fR, \fB\-\-version
-Print the installed version of mtr.  
+Print the installed version of mtr.
 .TP
 .B \-4
 Use IPv4 only.
@@ -157,33 +157,33 @@ Use IPv6 only.  (IPV4 may be used for DNS lookups.)
 Reads the list of hostnames from the specified file.
 .TP
 .B \-r\fR, \fB\-\-report
-This option puts 
+This option puts
 .B mtr
-into 
+into
 .B report
 mode.  When in this mode,
 .B mtr
-will run for the number of cycles specified by the 
+will run for the number of cycles specified by the
 .B \-c
-option, and then print statistics and exit.  
+option, and then print statistics and exit.
 .TP
 \c
-This mode is useful for generating statistics about network quality.  
-Note that each running instance of 
+This mode is useful for generating statistics about network quality.
+Note that each running instance of
 .B mtr
-generates a significant amount of network traffic.  Using 
+generates a significant amount of network traffic.  Using
 .B mtr
 to measure the quality of your network may result in decreased
-network performance.  
+network performance.
 .TP
 .B \-w\fR, \fB\-\-report\-wide
-This option puts 
+This option puts
 .B mtr
-into 
+into
 .B wide report
 mode.  When in this mode,
 .B mtr
-will not cut hostnames in the report. 
+will not cut hostnames in the report.
 .TP
 .B \-x\fR, \fB\-\-xml
 Use this option to tell
@@ -192,12 +192,12 @@ to use the xml output format.  This format is better suited for
 automated processing of the measurement results.
 .TP
 .B \-t\fR, \fB\-\-curses
-Use this option to force 
-.B mtr 
+Use this option to force
+.B mtr
 to use the curses based terminal
 interface (if available).
-In case the list of hops exceeds the 
-height of your terminal, you can use the 
+In case the list of hops exceeds the
+height of your terminal, you can use the
 .B +
 and
 .B -
@@ -215,19 +215,19 @@ information.
 .TP
 .B \-g\fR, \fB\-\-gtk
 Use this option to force
-.B mtr 
-to use the GTK+ based X11 window interface (if available).  
-GTK+ must have been available on the system when 
-.B mtr 
-was built for this to work.  See the GTK+ web page at 
+.B mtr
+to use the GTK+ based X11 window interface (if available).
+GTK+ must have been available on the system when
+.B mtr
+was built for this to work.  See the GTK+ web page at
 .UR http://\:www.\:gtk.\:org/
 .UE
 for more information about GTK+.
 .TP
 .B \-l\fR, \fB\-\-raw
 Use the raw output format.  This format is better suited for
-archival of the measurement results.  It could be parsed to 
-be presented into any of the other display methods. 
+archival of the measurement results.  It could be parsed to
+be presented into any of the other display methods.
 .IP
 Example of the raw output format:
 .nf
@@ -273,14 +273,14 @@ was built for this to work.
 .TP
 .B \-p\fR, \fB\-\-split
 Use this option to set
-.B mtr 
+.B mtr
 to spit out a format that is suitable for a split-user interface.
 .TP
 .B \-n\fR, \fB\-\-no\-dns
-Use this option to force 
-.B mtr 
+Use this option to force
+.B mtr
 to display numeric IP numbers and not try to resolve the
-host names. 
+host names.
 .TP
 .B \-b\fR, \fB\-\-show\-ips
 Use this option to tell
@@ -288,7 +288,7 @@ Use this option to tell
 to display both the host names and numeric IP numbers.  In split mode
 this adds an extra field to the output.  In report mode, there is usually
 too little space to add the IPs, and they will be truncated.  Use the
-wide report (-w) mode to see the IPs in report mode. 
+wide report (-w) mode to see the IPs in report mode.
 .TP
 .B \-o \fIFIELDS\fR, \fB\-\-order \fIFIELDS
 Use this option to specify which fields to display and in which order.
@@ -354,7 +354,7 @@ root user may choose values between zero and one.
 .TP
 .B \-c \fICOUNT\fR, \fB\-\-report\-cycles \fICOUNT
 Use this option to set the number of pings sent to determine
-both the machines on the network and the reliability of 
+both the machines on the network and the reliability of
 those machines.  Each cycle lasts one second.
 .TP
 .B \-s \fIPACKETSIZE\fR, \fB\-\-psize \fIPACKETSIZE
@@ -378,8 +378,8 @@ Specifies value for type of service field in IP header.  Should be within range
 - 255.
 .TP
 .B \-e\fR, \fB\-\-mpls
-Use this option to tell 
-.B mtr 
+Use this option to tell
+.B mtr
 to display information from ICMP extensions for MPLS (RFC 4950)
 that are encoded in the response packets.
 .TP
@@ -501,15 +501,15 @@ can be controlled while it is running with the following keys:
   z       toggle ASN info on/off
   q       exit
 .SH BUGS
-Some modern routers give a lower priority to ICMP ECHO packets than 
+Some modern routers give a lower priority to ICMP ECHO packets than
 to other network traffic.  Consequently, the reliability of these
-routers reported by 
+routers reported by
 .B mtr
-will be significantly lower than the actual reliability of 
-these routers.  
+will be significantly lower than the actual reliability of
+these routers.
 .SH CONTACT INFORMATION
 .PP
-For the latest version, see the mtr web page at 
+For the latest version, see the mtr web page at
 .UR http://\:www.\:bitwizard.\:nl/\:mtr/
 .UE
 .PP
diff --git a/packet/cmdparse.h b/packet/cmdparse.h
index 77c8281..e5cfeab 100644
--- a/packet/cmdparse.h
+++ b/packet/cmdparse.h
@@ -29,7 +29,7 @@ struct command_t {
     /*  A unique value for matching command requests with replies  */
     int token;
 
-    /*  Text indiciating the command type, or reply type  */
+    /*  Text indicating the command type, or reply type  */
     char *command_name;
 
     /*  The number of key, value argument pairs used  */
diff --git a/packet/command.c b/packet/command.c
index 2026352..b624ea6 100644
--- a/packet/command.c
+++ b/packet/command.c
@@ -424,7 +424,7 @@ void dispatch_buffer_commands(
     if (buffer->incoming_read_position >= COMMAND_BUFFER_SIZE - 1) {
         /*
            If we've filled the buffer without a complete command, the
-           only thing we can do is discard what we've read and hope that 
+           only thing we can do is discard what we've read and hope that
            new data is better formatted.
          */
         printf("0 command-buffer-overflow\n");
diff --git a/packet/construct_unix.c b/packet/construct_unix.c
index dff17d8..644536d 100644
--- a/packet/construct_unix.c
+++ b/packet/construct_unix.c
@@ -591,7 +591,7 @@ int construct_ip4_packet(
     /*
        The routing mark requires CAP_NET_ADMIN, as opposed to the
        CAP_NET_RAW which we are sometimes explicitly given.
-       If we don't have CAP_NET_ADMIN, this will fail, so we'll 
+       If we don't have CAP_NET_ADMIN, this will fail, so we'll
        only set the mark if the user has explicitly requested it.
 
        Unfortunately, this means that once the mark is set, it won't
diff --git a/packet/deconstruct_unix.c b/packet/deconstruct_unix.c
index 1af7419..61c6e91 100644
--- a/packet/deconstruct_unix.c
+++ b/packet/deconstruct_unix.c
@@ -99,22 +99,22 @@ void handle_inner_udp_packet(
     {
         saddr = &((struct IPHeader *)ip)->saddr;
         daddr = &((struct IPHeader *)ip)->daddr;
-    }else
+    } else
     if (af == AF_INET6)
     {
         daddr = &((struct IP6Header *)ip)->daddr;
         saddr = &((struct IP6Header *)ip)->saddr;
-    }else
+    } else
     {
         return;
     }
 
-    if( memcmp(sockaddr_addr_offset(&probe->remote_addr),
+    if ( memcmp(sockaddr_addr_offset(&probe->remote_addr),
                daddr,
                sockaddr_addr_size(&probe->remote_addr)) != 0 )
             return;
 
-    if( memcmp(sockaddr_addr_offset(&probe->local_addr),
+    if ( memcmp(sockaddr_addr_offset(&probe->local_addr),
            saddr,
            sockaddr_addr_size(&probe->local_addr)) != 0)
         return;
diff --git a/packet/packet.c b/packet/packet.c
index a8c2b6e..3821d91 100644
--- a/packet/packet.c
+++ b/packet/packet.c
@@ -35,7 +35,7 @@
 
 #include "wait.h"
 
-/*  Drop SUID privileges.  To be used after accquiring raw sockets.  */
+/*  Drop SUID privileges.  To be used after acquiring raw sockets.  */
 static
 int drop_elevated_permissions(
     void)
@@ -82,7 +82,7 @@ int main(
     struct net_state_t net_state;
 
     /*
-       To minimize security risk, the only thing done prior to 
+       To minimize security risk, the only thing done prior to
        dropping SUID should be opening the network state for
        raw sockets.
      */
diff --git a/packet/probe.c b/packet/probe.c
index 48f11b6..6581015 100644
--- a/packet/probe.c
+++ b/packet/probe.c
@@ -319,7 +319,7 @@ int find_source_addr(
     int len;
     struct sockaddr_storage dest_with_port;
 #ifdef __linux__
-    // The Linux code needs these. 
+    // The Linux code needs these.
     struct sockaddr_in *srcaddr4;
     struct sockaddr_in6 *srcaddr6;
 #endif
diff --git a/packet/probe_cygwin.c b/packet/probe_cygwin.c
index ab477be..f41e514 100644
--- a/packet/probe_cygwin.c
+++ b/packet/probe_cygwin.c
@@ -352,7 +352,7 @@ void icmp_send_probe(
         timeout = 1000 * request->timeout;
     } else {
         /*
-           IcmpSendEcho2 will return invalid argument on a timeout of 
+           IcmpSendEcho2 will return invalid argument on a timeout of
            zero.  Our Unix implementation allows it.  Bump up the timeout
            to 1 millisecond.
          */
diff --git a/packet/probe_unix.c b/packet/probe_unix.c
index e77e46f..f7f393f 100644
--- a/packet/probe_unix.c
+++ b/packet/probe_unix.c
@@ -153,7 +153,7 @@ void check_length_order(
 
     if (resolve_probe_addresses(net_state, &param, &p0.remote_addr,
                 &p0.local_addr)) {
-        fprintf(stderr, "Error decoding localhost address (%s/%s)\n", 
+        fprintf(stderr, "Error decoding localhost address (%s/%s)\n",
                 probe_err, strerror (errno));
         exit(EXIT_FAILURE);
     }
@@ -575,18 +575,18 @@ void send_probe(
         error(EXIT_FAILURE, errno, "gettimeofday failure");
     }
 
-    // there might be an off-by-one in the number of tries here. 
+    // there might be an off-by-one in the number of tries here.
     // this is intentional.  It is no use exhausting the very last
-    // open port. Max 10 retries would've been acceptable too I think. 
+    // open port. Max 10 retries would've been acceptable too I think.
     for (trytimes=MIN_PORT; trytimes < MAX_PORT; trytimes++) {
-			
+
         packet_size = construct_packet(net_state, &probe->platform.socket,
                          probe, packet, PACKET_BUFFER_SIZE,
                          param);
 
         if (packet_size > 0) break; // no retry if we succeed.
 
-        if ((param->protocol != IPPROTO_TCP) && 
+        if ((param->protocol != IPPROTO_TCP) &&
             (param->protocol != IPPROTO_SCTP)) break; // no retry if not TCP/SCTP
 
         if ((errno != EADDRINUSE) && (errno != EADDRNOTAVAIL)) {
@@ -594,7 +594,7 @@ void send_probe(
         }
 
      	probe->sequence = net_state->platform.next_sequence++;
-        	
+
        	if (net_state->platform.next_sequence > MAX_PORT) {
             net_state->platform.next_sequence = MIN_PORT;
         }
diff --git a/packet/probe_unix.h b/packet/probe_unix.h
index 0ce7657..f217a66 100644
--- a/packet/probe_unix.h
+++ b/packet/probe_unix.h
@@ -20,7 +20,7 @@
 #define PROBE_UNIX_H
 
 #ifndef IPPROTO_SCTP
-// Needed for Netbsd. 
+// Needed for Netbsd.
 #define IPPROTO_SCTP           132             /* SCTP */
 #endif
 
diff --git a/packet/protocols.h b/packet/protocols.h
index 89d0a96..51fce9a 100644
--- a/packet/protocols.h
+++ b/packet/protocols.h
@@ -50,7 +50,7 @@
 #define HTTP_PORT 80
 
 /*  We can't rely on header files to provide this information, because
-    the fields have different names between, for instance, Linux and 
+    the fields have different names between, for instance, Linux and
     Solaris  */
 struct ICMPHeader {
     uint8_t type;
diff --git a/packet/sockaddr.c b/packet/sockaddr.c
index 2a4b34a..892d7ee 100644
--- a/packet/sockaddr.c
+++ b/packet/sockaddr.c
@@ -5,14 +5,14 @@
 
 void *sockaddr_addr_offset(const void *x)
 {
-	if( x == NULL )
+	if ( x == NULL )
 		return NULL;
 
-	if( ((struct sockaddr *)(x))->sa_family == AF_INET )
+	if ( ((struct sockaddr *)(x))->sa_family == AF_INET )
 	{
 		return ((void *)(x) + offsetof(struct sockaddr_in, sin_addr));
-	}else
-	if( ((struct sockaddr *)(x))->sa_family == AF_INET6 )
+	} else
+	if ( ((struct sockaddr *)(x))->sa_family == AF_INET6 )
 	{
 		return ((void *)(x) + offsetof(struct sockaddr_in6, sin6_addr));
 	}
@@ -22,13 +22,13 @@ void *sockaddr_addr_offset(const void *x)
 
 unsigned int sockaddr_addr_size(const void *x)
 {
-	if( x == NULL )
+	if ( x == NULL )
 		return 0;
-	if( ((struct sockaddr *)(x))->sa_family == AF_INET )
+	if ( ((struct sockaddr *)(x))->sa_family == AF_INET )
 	{
 		return sizeof(struct in_addr);
-	}else
-	if( ((struct sockaddr *)(x))->sa_family == AF_INET6 )
+	} else
+	if ( ((struct sockaddr *)(x))->sa_family == AF_INET6 )
 	{
 		return sizeof(struct in6_addr);
 	}
@@ -38,13 +38,13 @@ unsigned int sockaddr_addr_size(const void *x)
 
 unsigned int sockaddr_size(const void *x)
 {
-	if( x == NULL )
+	if ( x == NULL )
 		return 0;
-	if( ((struct sockaddr *)(x))->sa_family == AF_INET )
+	if ( ((struct sockaddr *)(x))->sa_family == AF_INET )
 	{
 		return sizeof(struct sockaddr_in);
-	}else
-	if( ((struct sockaddr *)(x))->sa_family == AF_INET6 )
+	} else
+	if ( ((struct sockaddr *)(x))->sa_family == AF_INET6 )
 	{
 		return sizeof(struct sockaddr_in6);
 	}
@@ -53,14 +53,14 @@ unsigned int sockaddr_size(const void *x)
 
 in_port_t *sockaddr_port_offset(const void *x)
 {
-	if( x == NULL )
+	if ( x == NULL )
 		return NULL;
 
-	if( ((struct sockaddr *)(x))->sa_family == AF_INET )
+	if ( ((struct sockaddr *)(x))->sa_family == AF_INET )
 	{
 		return ((void *)(x) + offsetof(struct sockaddr_in, sin_port));
-	}else
-	if( ((struct sockaddr *)(x))->sa_family == AF_INET6 )
+	} else
+	if ( ((struct sockaddr *)(x))->sa_family == AF_INET6 )
 	{
 		return ((void *)(x) + offsetof(struct sockaddr_in6, sin6_port));
 	}
diff --git a/portability/getopt.c b/portability/getopt.c
index fcd0b7d..0c6a1b9 100644
--- a/portability/getopt.c
+++ b/portability/getopt.c
@@ -550,7 +550,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
 		    fprintf (stderr,
 		     _("%s: option `%c%s' doesn't allow an argument\n"),
 		     argv[0], argv[optind - 1][0], pfound->name);
-		  } 
+		  }
 		  nextchar += strlen (nextchar);
 		  return '?';
 		}
diff --git a/portability/queue.h b/portability/queue.h
index d19a425..e1222db 100644
--- a/portability/queue.h
+++ b/portability/queue.h
@@ -305,7 +305,7 @@ struct {								\
 #define	STAILQ_FIRST(head)	((head)->stqh_first)
 
 #define	STAILQ_FOREACH(var, head, field)				\
-	for((var) = STAILQ_FIRST((head));				\
+	for ((var) = STAILQ_FIRST((head));				\
 	   (var);							\
 	   (var) = STAILQ_NEXT((var), field))
 
diff --git a/test/probe.py b/test/probe.py
index b1f0fff..df5f496 100755
--- a/test/probe.py
+++ b/test/probe.py
@@ -17,7 +17,7 @@
 #   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
 
-'''Test sending probes and receiving respones.'''
+'''Test sending probes and receiving responses.'''
 
 import socket
 import sys
@@ -136,7 +136,7 @@ class TestProbeICMPv4(mtrpacket.MtrPacketTest):
         'Test timeouts when sending to a non-existant address'
 
         #
-        #  Probe a non-existant address, and expect no reply
+        #  Probe a non-existent address, and expect no reply
         #
         #  I'm not sure what the best way to find an address that doesn't
         #  exist, but is still route-able.  If we use a reserved IP
@@ -268,9 +268,10 @@ class TestProbeICMPv6(mtrpacket.MtrPacketTest):
     '''Test sending probes using IP version 6'''
 
     def __init__(self, *args):
-        google_addr = resolve_ipv6_address(mtrpacket.IPV6_TEST_HOST)
+        if mtrpacket.HAVE_IPV6:
+            google_addr = resolve_ipv6_address(mtrpacket.IPV6_TEST_HOST)
 
-        self.google_addr = google_addr  # type: str
+            self.google_addr = google_addr  # type: str
 
         super(TestProbeICMPv6, self).__init__(*args)
 
diff --git a/ui/asn.c b/ui/asn.c
index 2310a1b..3f424e0 100644
--- a/ui/asn.c
+++ b/ui/asn.c
@@ -207,11 +207,11 @@ static void reverse_host6(
 {
     int i;
     char *b = buff;
-    for (i = (sizeof(*addr) / 2 - 1); i >= 0; i--, b += 4)      /* 64b portion */
+    // We need to process the top 64 bits, or 8 bytes.
+    for (i = 8-1; i >= 0; i--, b += 4, buff_length -= 4)
         snprintf(b, buff_length,
                  "%x.%x.", addr->s6_addr[i] & 0xf, addr->s6_addr[i] >> 4);
-
-    buff[strlen(buff) - 1] = '\0';
+    *--b = 0;
 }
 #endif
 
diff --git a/ui/cmdpipe.c b/ui/cmdpipe.c
index a919754..d22b236 100644
--- a/ui/cmdpipe.c
+++ b/ui/cmdpipe.c
@@ -231,8 +231,8 @@ void execute_packet_child(
      */
     execlp(mtr_packet_path, "mtr-packet", (char *) NULL);
 
-    /* 
-       Then try to find it where WE were executed from.  
+    /*
+       Then try to find it where WE were executed from.
      */
     strncpy (buf, myname, 240);
     strcat (buf, "-packet");
@@ -355,7 +355,7 @@ void construct_base_command(
     const char *local_ip_type;
     const char *protocol = NULL;
 
-    /*  Conver the remote IP address to a string  */
+    /*  Convert the remote IP address to a string  */
     if (inet_ntop(ctl->af, address, ip_string, INET6_ADDRSTRLEN) == NULL) {
 
         display_close(ctl);
@@ -742,7 +742,7 @@ void consume_reply_buffer(
 
     /*
        We may have multiple completed replies.  Loop until we don't
-       have any more newlines termininating replies.
+       have any more newlines terminating replies.
      */
     while (true) {
         /*  If no newline is found, our reply isn't yet complete  */
@@ -803,7 +803,7 @@ void handle_command_replies(
     reply_buffer = cmdpipe->reply_buffer;
 
     /*
-       Read the available reply text, up to the the remaining
+       Read the available reply text, up to the remaining
        buffer space.  (Minus one for the terminating NUL.)
      */
     read_buffer = &reply_buffer[cmdpipe->reply_buffer_used];
diff --git a/ui/curses.c b/ui/curses.c
index 34bf30d..d01e178 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -3,7 +3,7 @@
     Copyright (C) 1997,1998  Matt Kimball
 
     This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License version 2 as 
+    it under the terms of the GNU General Public License version 2 as
     published by the Free Software Foundation.
 
     This program is distributed in the hope that it will be useful,
@@ -390,7 +390,7 @@ static void format_field(
         format_number(n, 5, dst);
     } else if (strchr(format, 'f')) {
         /* this is for fields where we measure integer microseconds but
-           display floating point miliseconds. Convert to float here. */
+           display floating point milliseconds. Convert to float here. */
         snprintf(dst, dst_length, format, n / 1000.0);
         /* this was marked as a temporary hack over 10 years ago. -- REW */
     } else {
@@ -432,15 +432,15 @@ static void mtr_curses_hosts(
                 attron(A_BOLD);
 #ifdef HAVE_IPINFO
             if (is_printii(ctl))
-                printw(fmt_ipinfo(ctl, addr));
+                printw("%s", fmt_ipinfo(ctl, addr));
 #endif
             if (name != NULL) {
                 if (ctl->show_ips)
-                    printw("%s (%s)", name, strlongip(ctl, addr));
+                    printw("%s (%s)", name, strlongip(ctl->af, addr));
                 else
                     printw("%s", name);
             } else {
-                printw("%s", strlongip(ctl, addr));
+                printw("%s", strlongip(ctl->af, addr));
             }
             attroff(A_BOLD);
 
@@ -451,7 +451,7 @@ static void mtr_curses_hosts(
             hd_len = 0;
             for (i = 0; i < MAXFLD; i++) {
                 /* Ignore options that don't exist */
-                /* On the other hand, we now check the input side. Shouldn't happen, 
+                /* On the other hand, we now check the input side. Shouldn't happen,
                    can't be careful enough. */
                 j = ctl->fld_index[ctl->fld_active[i]];
                 if (j == -1)
@@ -485,15 +485,15 @@ static void mtr_curses_hosts(
                 printw("\n    ");
 #ifdef HAVE_IPINFO
                 if (is_printii(ctl))
-                    printw(fmt_ipinfo(ctl, addrs));
+                    printw("%s", fmt_ipinfo(ctl, addrs));
 #endif
                 if (name != NULL) {
                     if (ctl->show_ips)
-                        printw("%s (%s)", name, strlongip(ctl, addrs));
+                        printw("%s (%s)", name, strlongip(ctl->af, addrs));
                     else
                         printw("%s", name);
                 } else {
-                    printw("%s", strlongip(ctl, addrs));
+                    printw("%s", strlongip(ctl->af, addrs));
                 }
                 for (k = 0; k < mplss->labels && ctl->enablempls; k++) {
                     printw("\n    [MPLS: Lbl %lu TC %u S %u TTL %u]",
@@ -650,10 +650,10 @@ static void mtr_curses_graph(
 
 #ifdef HAVE_IPINFO
             if (is_printii(ctl))
-                printw(fmt_ipinfo(ctl, addr));
+                printw("%s", fmt_ipinfo(ctl, addr));
 #endif
             name = dns_lookup(ctl, addr);
-            printw("%s", name ? name : strlongip(ctl, addr));
+            printw("%s", name ? name : strlongip(ctl->af, addr));
         } else {
             attron(A_BOLD);
             printw("(%s)", host_error_to_string(err));
@@ -698,9 +698,11 @@ void mtr_curses_redraw(
     pwcenter(buf);
     attroff(A_BOLD);
 
-    mvprintw(1, 0, "%s (%s) -> %s", ctl->LocalHostname, net_localaddr(), ctl->Hostname);
+    mvprintw(1, 0, "%s (%s) -> %s (%s)",
+	ctl->LocalHostname, net_localaddr(),
+	ctl->Hostname, net_remoteaddr());
     t = time(NULL);
-    mvprintw(1, maxx - 25, iso_time(&t));
+    mvprintw(1, maxx - 25, "%s", iso_time(&t));
     printw("\n");
 
     printw("Keys:  ");
@@ -760,7 +762,7 @@ void mtr_curses_redraw(
         startstat = padding - 2;
 
         snprintf(msg, sizeof(msg), " Last %3d pings", max_cols);
-        mvprintw(rowstat - 1, startstat, msg);
+        mvprintw(rowstat - 1, startstat, "%s", msg);
 
         attroff(A_BOLD);
         move(rowstat, 0);
diff --git a/ui/display.c b/ui/display.c
index 7127be5..e457b59 100644
--- a/ui/display.c
+++ b/ui/display.c
@@ -3,7 +3,7 @@
     Copyright (C) 1997,1998  Matt Kimball
 
     This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License version 2 as 
+    it under the terms of the GNU General Public License version 2 as
     published by the Free Software Foundation.
 
     This program is distributed in the hope that it will be useful,
diff --git a/ui/display.h b/ui/display.h
index 3eaa291..0c16e90 100644
--- a/ui/display.h
+++ b/ui/display.h
@@ -3,7 +3,7 @@
     Copyright (C) 1997,1998  Matt Kimball
 
     This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License version 2 as 
+    it under the terms of the GNU General Public License version 2 as
     published by the Free Software Foundation.
 
     This program is distributed in the hope that it will be useful,
@@ -18,7 +18,7 @@
 
 #include <netinet/in.h>
 
-/* Don't put a trailing comma in enumeration lists. Some compilers 
+/* Don't put a trailing comma in enumeration lists. Some compilers
    (notably the one on Irix 5.2) do not like that. */
 enum { ActionNone, ActionQuit, ActionReset, ActionDisplay,
     ActionClear, ActionPause, ActionResume, ActionMPLS, ActionDNS,
diff --git a/ui/dns.c b/ui/dns.c
index 7dc8885..824b401 100644
--- a/ui/dns.c
+++ b/ui/dns.c
@@ -3,7 +3,7 @@
     Copyright (C) 1997,1998  Matt Kimball
 
     This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License version 2 as 
+    it under the terms of the GNU General Public License version 2 as
     published by the Free Software Foundation.
 
     This program is distributed in the hope that it will be useful,
@@ -52,13 +52,13 @@ struct dns_results {
 static struct dns_results *results;
 
 char *strlongip(
-    struct mtr_ctl *ctl,
+    sa_family_t family,
     ip_t * ip)
 {
 #ifdef ENABLE_IPV6
     static char addrstr[INET6_ADDRSTRLEN];
 
-    return (char *) inet_ntop(ctl->af, ip, addrstr, sizeof addrstr);
+    return (char *) inet_ntop(family, ip, addrstr, sizeof addrstr);
 #else
     return inet_ntoa(*ip);
 #endif
@@ -87,18 +87,6 @@ static int longipstr(
 }
 
 
-struct hostent *dns_forward(
-    const char *name)
-{
-    struct hostent *host;
-
-    if ((host = gethostbyname(name)))
-        return host;
-    else
-        return NULL;
-}
-
-
 static struct dns_results *findip(
     struct mtr_ctl *ctl,
     ip_t * ip)
@@ -114,17 +102,17 @@ static struct dns_results *findip(
 }
 
 static void set_sockaddr_ip(
-    struct mtr_ctl *ctl,
+    sa_family_t family,
     struct sockaddr_storage *sa,
     ip_t * ip)
 {
     memset(sa, 0, sizeof(struct sockaddr_storage));
-    sa->ss_family = ctl->af;
+    sa->ss_family = family;
     memcpy(sockaddr_addr_offset(sa), ip, sockaddr_addr_size(sa));
 }
 
 void dns_open(
-    struct mtr_ctl *ctl)
+    void)
 {
     int pid;
 
@@ -173,16 +161,17 @@ void dns_open(
 
                 buf[strlen(buf) - 1] = 0;       /* chomp newline. */
 
-                longipstr(buf, &host, ctl->af);
-                set_sockaddr_ip(ctl, &sa, &host);
-                salen = (ctl->af == AF_INET) ? sizeof(struct sockaddr_in) :
+                sa_family_t family = (buf[0] == '4') ? AF_INET : AF_INET6;
+                longipstr(buf +1, &host, family);
+                set_sockaddr_ip(family, &sa, &host);
+                salen = (family == AF_INET) ? sizeof(struct sockaddr_in) :
                     sizeof(struct sockaddr_in6);
 
                 rv = getnameinfo((struct sockaddr *) &sa, salen,
                                  hostname, sizeof(hostname), NULL, 0, 0);
                 if (rv == 0) {
                     snprintf(result, sizeof(result),
-                             "%s %s\n", strlongip(ctl, &host), hostname);
+                             "%s %s\n", strlongip(family, &host), hostname);
 
                     rv = write(fromdns[1], result, strlen(result));
                     if (rv < 0)
@@ -256,7 +245,7 @@ char *dns_lookup2(
     ip_t * ip)
 {
     struct dns_results *r;
-    char buf[INET6_ADDRSTRLEN + 1];
+    char buf[INET6_ADDRSTRLEN + 2]; // af_byte + addr + null
     int rv;
 
     r = findip(ctl, ip);
@@ -270,7 +259,8 @@ char *dns_lookup2(
         r->name = NULL;
         r->next = results;
         results = r;
-        snprintf(buf, sizeof(buf), "%s\n", strlongip(ctl, ip));
+        char ip4or6 = (ctl->af == AF_INET) ? '4' : '6';
+        snprintf(buf, sizeof(buf), "%c%s\n", ip4or6, strlongip(ctl->af, ip));
         rv = write(todns[1], buf, strlen(buf));
         if (rv < 0)
             error(0, errno, "couldn't write to resolver process");
@@ -288,7 +278,7 @@ char *dns_lookup(
     if (!ctl->dns || !ctl->use_dns)
         return NULL;
     t = dns_lookup2(ctl, ip);
-    return t ? t : strlongip(ctl, ip);
+    return t ? t : strlongip(ctl->af, ip);
 }
 
 /* XXX check if necessary/exported. */
diff --git a/ui/dns.h b/ui/dns.h
index c04d184..52ce1b7 100644
--- a/ui/dns.h
+++ b/ui/dns.h
@@ -3,7 +3,7 @@
     Copyright (C) 1997,1998  Matt Kimball
 
     This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License version 2 as 
+    it under the terms of the GNU General Public License version 2 as
     published by the Free Software Foundation.
 
     This program is distributed in the hope that it will be useful,
@@ -23,7 +23,7 @@
 /*  Prototypes for dns.c  */
 
 extern void dns_open(
-    struct mtr_ctl *ctl);
+    void);
 extern int dns_waitfd(
     void);
 extern void dns_ack(
@@ -41,10 +41,8 @@ extern char *dns_lookup(
 extern char *dns_lookup2(
     struct mtr_ctl *ctl,
     ip_t * address);
-extern struct hostent *dns_forward(
-    const char *name);
 extern char *strlongip(
-    struct mtr_ctl *ctl,
+    sa_family_t family,
     ip_t * ip);
 
 extern void addr2ip6arpa(
diff --git a/ui/gtk.c b/ui/gtk.c
index dd79efc..742c5c9 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -4,7 +4,7 @@
     Changes/additions Copyright (C) 1998 R.E.Wolff@BitWizard.nl
 
     This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License version 2 as 
+    it under the terms of the GNU General Public License version 2 as
     published by the Free Software Foundation.
 
     This program is distributed in the hope that it will be useful,
@@ -94,7 +94,7 @@ int gtk_detect(
 {
     if (getenv("DISPLAY") != NULL) {
         /* If we do this here, gtk_init exits on an error. This happens
-           BEFORE the user has had a chance to tell us not to use the 
+           BEFORE the user has had a chance to tell us not to use the
            display... */
         return TRUE;
     } else {
@@ -244,11 +244,14 @@ static gint Host_activate(
     gpointer data)
 {
     struct mtr_ctl *ctl = (struct mtr_ctl *) data;
-    struct hostent *addr;
-
-    addr = dns_forward(gtk_entry_get_text(GTK_ENTRY(entry)));
-    if (addr) {
-        net_reopen(ctl, addr);
+    struct addrinfo *res = NULL;
+
+    ctl->af = DEFAULT_AF;  // should this obey the cmd line option?
+    ctl->Hostname = gtk_entry_get_text(GTK_ENTRY(entry));
+    if (get_addrinfo_from_name(ctl, &res, ctl->Hostname) == 0) {
+        net_reopen(ctl, res);
+        freeaddrinfo(res);
+        net_send_batch(ctl);
         /* If we are "Paused" at this point it is usually because someone
            entered a non-existing host. Therefore do the go-ahead... */
         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(Pause_Button), 0);
@@ -511,11 +514,11 @@ static void update_tree_row(
         if ((name = dns_lookup(ctl, addr))) {
             if (ctl->show_ips) {
                 snprintf(str, sizeof(str), "%s (%s)", name,
-                         strlongip(ctl, addr));
+                         strlongip(ctl->af, addr));
                 name = str;
             }
         } else
-            name = strlongip(ctl, addr);
+            name = strlongip(ctl->af, addr);
     }
 
     gtk_list_store_set(ReportStore, iter,
@@ -565,7 +568,7 @@ void gtk_redraw(
 }
 
 // GTK 3 has changed the interface a bit. Here a few defines so that we can
-// work with GTK2 or GTK3 as required. 
+// work with GTK2 or GTK3 as required.
 #ifdef HAVE_GTK3
 #define gtk_vbox_new_(orientation,sz) gtk_box_new(orientation, sz)
 #define gtk_hbox_new_(orientation,sz) gtk_box_new(orientation, sz)
diff --git a/ui/mtr-curses.h b/ui/mtr-curses.h
index 7bb1975..4f3359f 100644
--- a/ui/mtr-curses.h
+++ b/ui/mtr-curses.h
@@ -3,7 +3,7 @@
     Copyright (C) 1997,1998  Matt Kimball
 
     This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License version 2 as 
+    it under the terms of the GNU General Public License version 2 as
     published by the Free Software Foundation.
 
     This program is distributed in the hope that it will be useful,
diff --git a/ui/mtr-gtk.h b/ui/mtr-gtk.h
index 524de1c..a3691f5 100644
--- a/ui/mtr-gtk.h
+++ b/ui/mtr-gtk.h
@@ -3,7 +3,7 @@
     Copyright (C) 1997,1998  Matt Kimball
 
     This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License version 2 as 
+    it under the terms of the GNU General Public License version 2 as
     published by the Free Software Foundation.
 
     This program is distributed in the hope that it will be useful,
diff --git a/ui/mtr.c b/ui/mtr.c
index b33a136..2c6fc68 100644
--- a/ui/mtr.c
+++ b/ui/mtr.c
@@ -38,7 +38,6 @@
 #include <sys/limits.h>
 #endif
 
-#include <netdb.h>
 #include <netinet/in.h>
 #include <sys/socket.h>
 #include <ctype.h>
@@ -63,13 +62,6 @@
 #include "portability/getopt.h"
 #endif
 
-#ifdef ENABLE_IPV6
-#define DEFAULT_AF AF_UNSPEC
-#else
-#define DEFAULT_AF AF_INET
-#endif
-
-
 char *myname;
 
 const struct fields data_fields[MAXFLD] = {
@@ -150,7 +142,9 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out)
     fputs(" -w, --report-wide          output wide report\n", out);
     fputs(" -c, --report-cycles COUNT  set the number of pings sent\n",
           out);
+#ifdef HAVE_JANSSON
     fputs(" -j, --json                 output json\n", out);
+#endif
     fputs(" -x, --xml                  output xml\n", out);
     fputs(" -C, --csv                  output comma separated values\n",
           out);
@@ -696,31 +690,25 @@ static void init_rand(
     srand((getpid() << 16) ^ getuid() ^ tv.tv_sec ^ tv.tv_usec);
 }
 
-
 /*
     For historical reasons, we need a hostent structure to represent
     our remote target for probing.  The obsolete way of doing this
     would be to use gethostbyname().  We'll use getaddrinfo() instead
     to generate the hostent.
 */
-static int get_hostent_from_name(
+int get_addrinfo_from_name(
     struct mtr_ctl *ctl,
-    struct hostent *host,
-    const char *name,
-    char **alptr)
+    struct addrinfo **res,
+    const char *name)
 {
     int gai_error;
-    struct addrinfo hints, *res;
-    struct sockaddr_in *sa4;
-#ifdef ENABLE_IPV6
-    struct sockaddr_in6 *sa6;
-#endif
+    struct addrinfo hints;
 
     /* gethostbyname2() is deprecated so we'll use getaddrinfo() instead. */
     memset(&hints, 0, sizeof hints);
     hints.ai_family = ctl->af;
     hints.ai_socktype = SOCK_DGRAM;
-    gai_error = getaddrinfo(name, NULL, &hints, &res);
+    gai_error = getaddrinfo(name, NULL, &hints, res);
     if (gai_error) {
         if (gai_error == EAI_SYSTEM)
             error(0, 0, "Failed to resolve host: %s", name);
@@ -731,33 +719,7 @@ static int get_hostent_from_name(
         return -1;
     }
 
-    /* Convert the first addrinfo into a hostent. */
-    memset(host, 0, sizeof(struct hostent));
-    host->h_name = res->ai_canonname;
-    host->h_aliases = NULL;
-    host->h_addrtype = res->ai_family;
-    ctl->af = res->ai_family;
-    host->h_length = res->ai_addrlen;
-    host->h_addr_list = alptr;
-    switch (ctl->af) {
-    case AF_INET:
-        sa4 = (struct sockaddr_in *) res->ai_addr;
-        alptr[0] = (void *) &(sa4->sin_addr);
-        break;
-#ifdef ENABLE_IPV6
-    case AF_INET6:
-        sa6 = (struct sockaddr_in6 *) res->ai_addr;
-        alptr[0] = (void *) &(sa6->sin6_addr);
-        break;
-#endif
-    default:
-        error(0, 0, "unknown address type");
-
-        errno = EINVAL;
-        return -1;
-    }
-    alptr[1] = NULL;
-
+    ctl->af = (*res)->ai_family;
     return 0;
 }
 
@@ -766,9 +728,6 @@ int main(
     int argc,
     char **argv)
 {
-    struct hostent *host = NULL;
-    struct hostent trhost;
-    char *alptr[2];
     names_t *names_head = NULL;
     names_t *names_walk;
 
@@ -837,8 +796,8 @@ int main(
                      sizeof(ctl.LocalHostname));
         }
 
-        host = &trhost;
-        if (get_hostent_from_name(&ctl, host, ctl.Hostname, alptr) != 0) {
+        struct addrinfo *res = NULL;
+        if (get_addrinfo_from_name(&ctl, &res, ctl.Hostname) != 0) {
             if (ctl.Interactive)
                 exit(EXIT_FAILURE);
             else {
@@ -847,7 +806,7 @@ int main(
             }
         }
 
-        if (net_open(&ctl, host) != 0) {
+        if (net_open(&ctl, res) != 0) {
             error(0, 0, "Unable to start net module");
             if (ctl.Interactive)
                 exit(EXIT_FAILURE);
@@ -857,8 +816,10 @@ int main(
             }
         }
 
+        freeaddrinfo(res);
+
         lock(stdout);
-        dns_open(&ctl);
+        dns_open();
         display_open(&ctl);
 
         display_loop(&ctl);
diff --git a/ui/mtr.h b/ui/mtr.h
index 01536f5..8be1da9 100644
--- a/ui/mtr.h
+++ b/ui/mtr.h
@@ -4,7 +4,7 @@
     Copyright (C) 2005 R.E.Wolff@BitWizard.nl
 
     This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License version 2 as 
+    it under the terms of the GNU General Public License version 2 as
     published by the Free Software Foundation.
 
     This program is distributed in the hope that it will be useful,
@@ -23,6 +23,7 @@
 #include "config.h"
 
 #include <stdint.h>
+#include <netdb.h>
 #include <sys/socket.h>
 #include <arpa/inet.h>
 
@@ -32,8 +33,10 @@
 
 /* Typedefs */
 #ifdef ENABLE_IPV6
+#define DEFAULT_AF AF_UNSPEC
 typedef struct in6_addr ip_t;
 #else
+#define DEFAULT_AF AF_INET
 typedef struct in_addr ip_t;
 #endif
 
@@ -82,7 +85,7 @@ struct mtr_ctl {
     int MaxPing;
     float WaitTime;
     float GraceTime;
-    char *Hostname;
+    const char *Hostname;
     char *InterfaceName;
     char *InterfaceAddress;
     char LocalHostname[128];
@@ -146,4 +149,9 @@ struct mplslen {
 #define running_as_root() (getuid() == 0)
 #endif
 
+int get_addrinfo_from_name(
+    struct mtr_ctl *ctl,
+    struct addrinfo **res,
+    const char *name);
+
 #endif                          /* MTR_MTR_H */
diff --git a/ui/net.c b/ui/net.c
index f684b3e..efeb782 100644
--- a/ui/net.c
+++ b/ui/net.c
@@ -3,7 +3,7 @@
     Copyright (C) 1997,1998  Matt Kimball
 
     This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License version 2 as 
+    it under the terms of the GNU General Public License version 2 as
     published by the Free Software Foundation.
 
     This program is distributed in the hope that it will be useful,
@@ -97,11 +97,13 @@ static ip_t *remoteaddress;
 
 #ifdef ENABLE_IPV6
 static char localaddr[INET6_ADDRSTRLEN];
+static char remoteaddr[INET6_ADDRSTRLEN];
 #else
 #ifndef INET_ADDRSTRLEN
 #define INET_ADDRSTRLEN 16
 #endif
 static char localaddr[INET_ADDRSTRLEN];
+static char remoteaddr[INET_ADDRSTRLEN];
 #endif
 
 static int batch_at = 0;
@@ -239,22 +241,21 @@ static void net_process_ping(
 
 
     if (addrcmp(&nh->addr, &addrcopy, ctl->af) != 0) {
-        for (i = 0; i < MAX_PATH;) {
-            if (addrcmp(&nh->addrs[i], &nh->addr, ctl->af) == 0) {
+        for (i = 0; i < MAX_PATH; i++) {
+            if (addrcmp(&nh->addrs[i], &addrcopy, ctl->af) == 0) {
                 found = 1; /* This host is already in the list */
                 break;
             }
             if (addrcmp(&nh->addrs[i], &ctl->unspec_addr, ctl->af) == 0) {
                 break; /* Found first vacant position */
             }
-            i++;
         }
 
         if (found == 0 && i < MAX_PATH) {
-            memcpy(&nh->addrs[i], &nh->addr, sockaddr_addr_size(sourcesockaddr));
+            memcpy(&nh->addrs[i], &addrcopy, sockaddr_addr_size(sourcesockaddr));
 
-            nh->mplss[i] = nh->mpls;
-            display_rawhost(ctl, index, (void *)&(nh->addrs[i]), (void *)&(nh->addrs[i]));
+            nh->mplss[i] = *mpls;
+            display_rawhost(ctl, index, &nh->addrs[i], mpls);
         }
 
         /* Always save the latest host in nh->addr. This
@@ -262,7 +263,7 @@ static void net_process_ping(
          */
         memcpy(&nh->addr, addrcopy, sockaddr_addr_size(sourcesockaddr));
         nh->mpls = *mpls;
-        display_rawhost(ctl, index, (void *)&(nh->addr), (void *)&(nh->mpls));
+        display_rawhost(ctl, index, &nh->addr, mpls);
     }
 
     nh->jitter = totusec - nh->last;
@@ -332,7 +333,7 @@ void net_process_return(
 ip_t *net_addr(
     int at)
 {
-    return (ip_t *) & (host[at].addr);
+    return & (host[at].addr);
 }
 
 
@@ -340,7 +341,7 @@ ip_t *net_addrs(
     int at,
     int i)
 {
-    return (ip_t *) & (host[at].addrs[i]);
+    return & (host[at].addrs[i]);
 }
 
 /*
@@ -352,17 +353,17 @@ int net_err(
     return host[at].err;
 }
 
-void *net_mpls(
+struct mplslen *net_mpls(
     int at)
 {
-    return (struct mplslen *) &(host[at].mplss);
+    return & (host[at].mpls);
 }
 
-void *net_mplss(
+struct mplslen *net_mplss(
     int at,
     int i)
 {
-    return (struct mplslen *) &(host[at].mplss[i]);
+    return & (host[at].mplss[i]);
 }
 
 int net_loss(
@@ -523,6 +524,13 @@ char *net_localaddr(
 }
 
 
+char *net_remoteaddr(
+    void)
+{
+    return remoteaddr;
+}
+
+
 void net_end_transit(
     void)
 {
@@ -539,18 +547,18 @@ int net_send_batch(
     int n_unknown = 0, i;
     int restart = 0;
 
-    /* randomized packet size and/or bit pattern if packetsize<0 and/or 
-       bitpattern<0.  abs(packetsize) and/or abs(bitpattern) will be used 
+    /* randomized packet size and/or bit pattern if packetsize<0 and/or
+       bitpattern<0.  abs(packetsize) and/or abs(bitpattern) will be used
      */
     if (batch_at < ctl->fstTTL) {
         if (ctl->cpacketsize < 0) {
-            /* Someone used a formula here that tried to correct for the 
-               "end-error" in "rand()". By "end-error" I mean that if you 
-               have a range for "rand()" that runs to 32768, and the 
-               destination range is 10000, you end up with 4 out of 32768 
-               0-2768's and only 3 out of 32768 for results 2769 .. 9999. 
-               As our destination range (in the example 10000) is much 
-               smaller (reasonable packet sizes), and our rand() range much 
+            /* Someone used a formula here that tried to correct for the
+               "end-error" in "rand()". By "end-error" I mean that if you
+               have a range for "rand()" that runs to 32768, and the
+               destination range is 10000, you end up with 4 out of 32768
+               0-2768's and only 3 out of 32768 for results 2769 .. 9999.
+               As our destination range (in the example 10000) is much
+               smaller (reasonable packet sizes), and our rand() range much
                larger, this effect is insignificant. Oh! That other formula
                didn't work. */
             packetsize =
@@ -570,9 +578,9 @@ int net_send_batch(
         if (host_addr_cmp(i, &ctl->unspec_addr, ctl->af) == 0)
             n_unknown++;
 
-        /* The second condition in the next "if" statement was added in mtr-0.56, 
+        /* The second condition in the next "if" statement was added in mtr-0.56,
            but I don't remember why. It makes mtr stop skipping sections of unknown
-           hosts. Removed in 0.65. 
+           hosts. Removed in 0.65.
            If the line proves necessary, it should at least NOT trigger that line
            when host[i].addr == 0 */
         if (host_addr_cmp(i, remoteaddress, ctl->af) == 0) {
@@ -592,7 +600,7 @@ int net_send_batch(
         numhosts = batch_at + 1;
     }
 
-    if(restart) {
+    if (restart) {
         batch_at = ctl->fstTTL - 1;
         return 1;
     }
@@ -728,7 +736,7 @@ static void net_find_local_address(
 
 int net_open(
     struct mtr_ctl *ctl,
-    struct hostent *hostent)
+    struct addrinfo *res)
 {
     int err;
 
@@ -738,23 +746,7 @@ int net_open(
         return err;
     }
 
-    net_reset(ctl);
-
-    remotesockaddr->sa_family = sourcesockaddr->sa_family = hostent->h_addrtype;
-    memcpy(sockaddr_addr_offset(remotesockaddr), hostent->h_addr, sockaddr_addr_size(remotesockaddr));
-
-    sourceaddress = sockaddr_addr_offset(sourcesockaddr);
-    remoteaddress = sockaddr_addr_offset(remotesockaddr);
-
-    if (ctl->InterfaceAddress) {
-        net_validate_interface_address(ctl->af, ctl->InterfaceAddress);
-    } else if (ctl->InterfaceName) {
-        net_find_interface_address_from_name(
-            &sourcesockaddr_struct, ctl->af, ctl->InterfaceName);
-        inet_ntop(sourcesockaddr->sa_family, sockaddr_addr_offset(sourcesockaddr), localaddr, sizeof(localaddr));
-    } else {
-        net_find_local_address();
-    }
+    net_reopen(ctl, res);
 
     return 0;
 }
@@ -762,7 +754,7 @@ int net_open(
 
 void net_reopen(
     struct mtr_ctl *ctl,
-    struct hostent *addr)
+    struct addrinfo *res)
 {
     int at;
 
@@ -770,11 +762,25 @@ void net_reopen(
         memset(&host[at], 0, sizeof(host[at]));
     }
 
-    remotesockaddr->sa_family = addr->h_addrtype;
-    memcpy(remoteaddress, addr->h_addr, sockaddr_addr_size(remotesockaddr));
-    memcpy(sockaddr_addr_offset(remotesockaddr), addr->h_addr, sockaddr_addr_size(remotesockaddr));
     net_reset(ctl);
-    net_send_batch(ctl);
+
+    ctl->af = remotesockaddr->sa_family = sourcesockaddr->sa_family = res->ai_family;
+    remoteaddress = sockaddr_addr_offset(remotesockaddr);
+    memcpy(remoteaddress, sockaddr_addr_offset(res->ai_addr), sockaddr_addr_size(remotesockaddr));
+    inet_ntop(remotesockaddr->sa_family, remoteaddress, remoteaddr, sizeof(remoteaddr));
+
+    sourceaddress = sockaddr_addr_offset(sourcesockaddr);
+
+    if (ctl->InterfaceAddress) {
+        net_validate_interface_address(ctl->af, ctl->InterfaceAddress);
+    } else if (ctl->InterfaceName) {
+        net_find_interface_address_from_name(
+            &sourcesockaddr_struct, ctl->af, ctl->InterfaceName);
+        inet_ntop(sourcesockaddr->sa_family, sourceaddress, localaddr, sizeof(localaddr));
+    } else {
+        net_find_local_address();
+    }
+
 }
 
 
diff --git a/ui/net.h b/ui/net.h
index 8a0d775..354c998 100644
--- a/ui/net.h
+++ b/ui/net.h
@@ -3,7 +3,7 @@
     Copyright (C) 1997,1998  Matt Kimball
 
     This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License version 2 as 
+    it under the terms of the GNU General Public License version 2 as
     published by the Free Software Foundation.
 
     This program is distributed in the hope that it will be useful,
@@ -33,10 +33,10 @@
 
 extern int net_open(
     struct mtr_ctl *ctl,
-    struct hostent *host);
+    struct addrinfo *res);
 extern void net_reopen(
     struct mtr_ctl *ctl,
-    struct hostent *address);
+    struct addrinfo *res);
 extern void net_reset(
     struct mtr_ctl *ctl);
 extern void net_close(
@@ -58,9 +58,9 @@ extern ip_t *net_addr(
     int at);
 extern int net_err(
     int at);
-extern void *net_mpls(
+extern struct mplslen *net_mpls(
     int at);
-extern void *net_mplss(
+extern struct mplslen *net_mplss(
     int,
     int);
 extern int net_loss(
@@ -90,6 +90,8 @@ extern ip_t *net_addrs(
     int i);
 extern char *net_localaddr(
     void);
+extern char *net_remoteaddr(
+    void);
 
 extern int net_send_batch(
     struct mtr_ctl *ctl);
diff --git a/ui/raw.c b/ui/raw.c
index 0735131..74ed35f 100644
--- a/ui/raw.c
+++ b/ui/raw.c
@@ -5,7 +5,7 @@
     raw.c -- raw output (for logging for later analysis)
 
     This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License version 2 as 
+    it under the terms of the GNU General Public License version 2 as
     published by the Free Software Foundation.
 
     This program is distributed in the hope that it will be useful,
@@ -70,7 +70,7 @@ void raw_rawhost(
     ip_t *ip_addr,
     struct mplslen *mpls)
 {
-    printf("h %d %s\n", host, strlongip(ctl, ip_addr));
+    printf("h %d %s\n", host, strlongip(ctl->af, ip_addr));
     if (ctl->enablempls) {
         int k;
         for (k = 0; k < mpls->labels; k++)
diff --git a/ui/raw.h b/ui/raw.h
index 3c9a075..f3fde96 100644
--- a/ui/raw.h
+++ b/ui/raw.h
@@ -5,7 +5,7 @@
     raw.h -- raw output (for logging for later analysis)
 
     This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License version 2 as 
+    it under the terms of the GNU General Public License version 2 as
     published by the Free Software Foundation.
 
     This program is distributed in the hope that it will be useful,
diff --git a/ui/report.c b/ui/report.c
index b79f593..a63ed55 100644
--- a/ui/report.c
+++ b/ui/report.c
@@ -43,7 +43,7 @@
 #include "utils.h"
 
 #define MAXLOADBAL 5
-#define MAX_FORMAT_STR 81
+#define MAX_FORMAT_STR 320
 
 
 void report_open(
@@ -65,10 +65,10 @@ static size_t snprint_addr(
         struct hostent *host =
             ctl->dns ? addr2host((void *) addr, ctl->af) : NULL;
         if (!host)
-            return snprintf(dst, dst_len, "%s", strlongip(ctl, addr));
+            return snprintf(dst, dst_len, "%s", strlongip(ctl->af, addr));
         else if (ctl->dns && ctl->show_ips)
             return snprintf(dst, dst_len, "%s (%s)", host->h_name,
-                            strlongip(ctl, addr));
+                            strlongip(ctl->af, addr));
         else
             return snprintf(dst, dst_len, "%s", host->h_name);
     } else
@@ -170,7 +170,7 @@ void report_close(
             if (j < 0)
                 continue;
 
-            /* 1000.0 is a temporay hack for stats usec to ms, impacted net_loss. */
+            /* 1000.0 is a temporary hack for stats usec to ms, impacted net_loss. */
             if (strchr(data_fields[j].format, 'f')) {
                 snprintf(buf + len, sizeof(buf), data_fields[j].format,
                          data_fields[j].net_xxx(at) / 1000.0);
@@ -215,14 +215,14 @@ void report_close(
             if (!found) {
 
 #ifdef HAVE_IPINFO
+                if (mpls->labels && z == 1 && ctl->enablempls)
+                    print_mpls(mpls);
                 if (is_printii(ctl)) {
-                    if (mpls->labels && z == 1 && ctl->enablempls)
-                        print_mpls(mpls);
                     snprint_addr(ctl, name, sizeof(name), addr2);
                     printf("     %s%s\n", fmt_ipinfo(ctl, addr2), name);
-                    if (ctl->enablempls)
-                        print_mpls(mplss);
                 }
+                if (ctl->enablempls)
+                    print_mpls(mplss);
 #else
                 int k;
                 if (mpls->labels && z == 1 && ctl->enablempls) {
@@ -235,7 +235,7 @@ void report_close(
                 }
 
                 if (z == 1) {
-                    printf("    |  `|-- %s\n", strlongip(ctl, addr2));
+                    printf("    |  `|-- %s\n", strlongip(ctl->af, addr2));
                     for (k = 0; k < mplss->labels && ctl->enablempls; k++) {
                         printf
                             ("    |   +-- [MPLS: Lbl %lu TC %u S %u TTL %u]\n",
@@ -243,7 +243,7 @@ void report_close(
                              mplss->ttl[k]);
                     }
                 } else {
-                    printf("    |   |-- %s\n", strlongip(ctl, addr2));
+                    printf("    |   |-- %s\n", strlongip(ctl->af, addr2));
                     for (k = 0; k < mplss->labels && ctl->enablempls; k++) {
                         printf
                             ("    |   +-- [MPLS: Lbl %lu TC %u S %u TTL %u]\n",
@@ -344,7 +344,7 @@ void json_close(struct mtr_ctl *ctl)
             goto on_error;
 
 #ifdef HAVE_IPINFO
-        if(!ctl->ipinfo_no) {
+        if (!ctl->ipinfo_no) {
             char* fmtinfo = fmt_ipinfo(ctl, addr);
             if (fmtinfo != NULL)
                 fmtinfo = trim(fmtinfo, '\0');
@@ -385,7 +385,7 @@ void json_close(struct mtr_ctl *ctl)
     if (ret == -1)
         goto on_error;
 
-    printf("\n"); // bash promt should be on new line
+    printf("\n"); // bash prompt should be on new line
     json_decref(jreport);
     return;
 on_error:
@@ -447,7 +447,7 @@ void xml_close(
                 title = "Loss";
             }
 
-            /* 1000.0 is a temporay hack for stats usec to ms, impacted net_loss. */
+            /* 1000.0 is a temporary hack for stats usec to ms, impacted net_loss. */
             if (strchr(data_fields[j].format, 'f')) {
                 printf(name,
                        title, data_fields[j].net_xxx(at) / 1000.0, title);
@@ -470,8 +470,9 @@ void csv_close(
     struct mtr_ctl *ctl,
     time_t now)
 {
-    int i, j, at, max;
+    int i, j, at, max, z, w;
     ip_t *addr;
+    ip_t *addr2 = NULL;
     char name[MAX_FORMAT_STR];
 
     for (i = 0; i < MAXFLD; i++) {
@@ -518,7 +519,7 @@ void csv_close(
             if (j < 0)
                 continue;
 
-            /* 1000.0 is a temporay hack for stats usec to ms, impacted net_loss. */
+            /* 1000.0 is a temporary hack for stats usec to ms, impacted net_loss. */
             if (strchr(data_fields[j].format, 'f')) {
                 printf(",%.2f",
                        (double) (data_fields[j].net_xxx(at) / 1000.0));
@@ -527,5 +528,61 @@ void csv_close(
             }
         }
         printf("\n");
+        if (ctl->reportwide == 0)
+            continue;
+        
+        for (z = 0; z < MAX_PATH; z++) {
+            int found = 0;
+            addr2 = net_addrs(at, z);
+            snprint_addr(ctl, name, sizeof(name), addr2);
+            if ((addrcmp
+                    ((void *) &ctl->unspec_addr, (void *) addr2,
+                     ctl->af)) == 0) {
+                break;
+            } else if ((addrcmp
+                    ((void *) addr, (void *) addr2,
+                     ctl->af)) == 0) {
+                continue; /* Latest Host is already printed */
+            } else {
+                for (w = 0; w < z; w++)
+                    /* Ok... checking if there are ips repeated on same hop */
+                    if ((addrcmp
+                            ((void *) addr2, (void *) net_addrs(at, w),
+                             ctl->af)) == 0) {
+                        found = 1;
+                        break;
+                    }
+
+                if (!found) {
+#ifdef HAVE_IPINFO
+                    if (!ctl->ipinfo_no) {
+                        char *fmtinfo = fmt_ipinfo(ctl, addr2);
+                        fmtinfo = trim(fmtinfo, '\0');
+                        printf("MTR.%s,%lld,%s,%s,%d,%s,%s", PACKAGE_VERSION,
+                            (long long) now, "OK", ctl->Hostname, at + 1, name,
+                            fmtinfo);
+                    } else
+#endif
+                        printf("MTR.%s,%lld,%s,%s,%d,%s", PACKAGE_VERSION,
+                           (long long) now, "OK", ctl->Hostname, at + 1, name);
+
+                    /* Use values associated with the first ip discovered for this hop */
+                    for (i = 0; i < MAXFLD; i++) {
+                        j = ctl->fld_index[ctl->fld_active[i]];
+                        if (j < 0)
+                            continue;
+
+                        /* 1000.0 is a temporary hack for stats usec to ms, impacted net_loss. */
+                        if (strchr(data_fields[j].format, 'f')) {
+                            printf(",%.2f",
+                                   (double) (data_fields[j].net_xxx(at) / 1000.0));
+                        } else {
+                            printf(",%d", data_fields[j].net_xxx(at));
+                        }
+                    }
+                    printf("\n");
+                }
+            }    
+        }
     }
 }
diff --git a/ui/report.h b/ui/report.h
index 96eb46f..dffc431 100644
--- a/ui/report.h
+++ b/ui/report.h
@@ -3,7 +3,7 @@
     Copyright (C) 1997,1998  Matt Kimball
 
     This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License version 2 as 
+    it under the terms of the GNU General Public License version 2 as
     published by the Free Software Foundation.
 
     This program is distributed in the hope that it will be useful,
diff --git a/ui/select.c b/ui/select.c
index 26748ac..1a9f5c2 100644
--- a/ui/select.c
+++ b/ui/select.c
@@ -3,7 +3,7 @@
     Copyright (C) 1997,1998  Matt Kimball
 
     This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License version 2 as 
+    it under the terms of the GNU General Public License version 2 as
     published by the Free Software Foundation.
 
     This program is distributed in the hope that it will be useful,
diff --git a/ui/select.h b/ui/select.h
index a6b2764..6567b66 100644
--- a/ui/select.h
+++ b/ui/select.h
@@ -3,7 +3,7 @@
     Copyright (C) 1997,1998  Matt Kimball
 
     This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License version 2 as 
+    it under the terms of the GNU General Public License version 2 as
     published by the Free Software Foundation.
 
     This program is distributed in the hope that it will be useful,
diff --git a/ui/split.c b/ui/split.c
index d300404..c88b4fe 100644
--- a/ui/split.c
+++ b/ui/split.c
@@ -7,7 +7,7 @@
     Copyright (C) 1998  Bertrand Leconte <B.Leconte@mail.dotcom.fr>
 
     This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License version 2 as 
+    it under the terms of the GNU General Public License version 2 as
     published by the Free Software Foundation.
 
     This program is distributed in the hope that it will be useful,
@@ -77,7 +77,7 @@ void split_redraw(
     fprintf(stderr, "split_redraw()\n");
 #endif
 
-    /* 
+    /*
      * If there is less lines than last time, we delete them
      * TEST THIS PLEASE
      */
@@ -95,10 +95,10 @@ void split_redraw(
         if (addrcmp(addr, &ctl->unspec_addr, ctl->af)) {
             char str[256], *name;
             if (!(name = dns_lookup(ctl, addr)))
-                name = strlongip(ctl, addr);
+                name = strlongip(ctl->af, addr);
             if (ctl->show_ips) {
                 snprintf(str, sizeof(str), "%s %s", name,
-                         strlongip(ctl, addr));
+                         strlongip(ctl->af, addr));
                 name = str;
             }
             /* May be we should test name's length */
@@ -166,7 +166,7 @@ int split_keyaction(
     tv.tv_usec = 0;
 
     if (select(1, &readfds, NULL, NULL, &tv) > 0) {
-        if (read(0, &c, 1) <= 0) 
+        if (read(0, &c, 1) <= 0)
           return ActionQuit;
     } else
         return 0;
diff --git a/ui/split.h b/ui/split.h
index d6938c7..c2b6094 100644
--- a/ui/split.h
+++ b/ui/split.h
@@ -5,7 +5,7 @@
     Copyright (C) 1998  Bertrand Leconte <B.Leconte@mail.dotcom.fr>
 
     This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License version 2 as 
+    it under the terms of the GNU General Public License version 2 as
     published by the Free Software Foundation.
 
     This program is distributed in the hope that it will be useful,
diff --git a/ui/utils.c b/ui/utils.c
index bbdf69d..edd5905 100644
--- a/ui/utils.c
+++ b/ui/utils.c
@@ -176,7 +176,7 @@ void close_stdout(
         _exit(EXIT_FAILURE);
 }
 
-/* ctime() replacement that will reteturn ISO-8601 timestamp string such as:
+/* ctime() replacement that will return ISO-8601 timestamp string such as:
  * 2016-08-29T19:25:02+01:00 */
 const char *iso_time(
     const time_t * t)
