diff --git a/src/usr/local/pfSense/include/www/bandwidth_by_ip.inc b/src/usr/local/pfSense/include/www/bandwidth_by_ip.inc
index 174a4380a2..3ec3dfbc18 100644
--- a/src/usr/local/pfSense/include/www/bandwidth_by_ip.inc
+++ b/src/usr/local/pfSense/include/www/bandwidth_by_ip.inc
@@ -181,7 +181,14 @@ function printBandwidth($interface, $filter, $sort, $hostipformat, $mode) {
 						$addrdata = $iplookup[$infoarray[0]];
 					} else {
 						// Try to reverse lookup the IP address.
-						$addrdata = gethostbyaddr($infoarray[0]);
+						$ptr = gethostbyaddr($infoarray[0]);
+						/* Only use the result if it is a proper name or IP address. */
+						if (is_ipaddr($ptr) ||
+						    is_domain($ptr)) {
+							$addrdata = $ptr;
+						} else {
+							$addrdata = $infoarray[0];
+						}
 						if ($addrdata != $infoarray[0]) {
 							// Reverse lookup returned something other than the IP address (FQDN, we hope!)
 							if ($hostipformat != "fqdn") {
diff --git a/src/usr/local/www/status_graph.php b/src/usr/local/www/status_graph.php
index c6835a9f16..4648a01469 100644
--- a/src/usr/local/www/status_graph.php
+++ b/src/usr/local/www/status_graph.php
@@ -299,12 +299,13 @@ function updateBandwidth() {
 				for (var y=0; y<10; y++) {
 					if ((y < hosts_split.length) && (hosts_split[y] != "") && (hosts_split[y] != "no info")) {
 						hostinfo = hosts_split[y].split(";");
-
-						$('#top10-hosts').append('<tr>'+
-							'<td>'+ hostinfo[0] +'</td>'+
-							'<td>'+ hostinfo[1] +' <?=gettext("Bits/sec");?></td>'+
-							'<td>'+ hostinfo[2] +' <?=gettext("Bits/sec");?></td>'+
-						'</tr>');
+						$('#top10-hosts').append(
+							$('<tr>').append(
+								$('<td>').text(hostinfo[0]),
+								$('<td>').text(hostinfo[1] + ' ' + <?=json_encode(htmlspecialchars(gettext("Bits/sec")));?>),
+								$('<td>').text(hostinfo[2] + ' ' + <?=json_encode(htmlspecialchars(gettext("Bits/sec")));?>)
+							)
+						);
 					}
 				}
 			},
