diff -ruBbd cacti-0.8.7g/lib/database.php cacti-0.8.7g-patched/lib/database.php
--- cacti-0.8.7g/lib/database.php	2010-07-09 18:33:46.000000000 -0400
+++ cacti-0.8.7g-patched/lib/database.php	2010-08-31 20:31:22.000000000 -0400
@@ -38,14 +38,14 @@
 	$cnn = NewADOConnection($db_type);
 	$class = get_class($cnn);
 	
-	if (!is_a($cnn_id, $class)) {
-		$cnn_id = $cnn;
-	}
-
 	$hostport = $host . ":" . $port;
 
 	while ($i <= $retries) {
 		if ($cnn->PConnect($hostport,$user,$pass,$db_name)) {
+			if (!is_a($cnn_id, $class)) {
+				$cnn_id = $cnn;
+			}
+
 			return($cnn);
 		}
 
@@ -92,7 +92,7 @@
 	while (1) {
 		$query = $db_conn->Execute($sql);
 
-		if (($query) || ($db_conn->ErrorNo() == 1032)) {
+		if (($db_conn->ErrorNo() == 0) || ($db_conn->ErrorNo() == 1032)) {
 			return(1);
 		}else if (($db_conn->ErrorNo() == 1049) || ($db_conn->ErrorNo() == 1051)) {
 			printf("FATAL: Database or Table does not exist");
@@ -143,7 +143,7 @@
 
 	$query = $db_conn->Execute($sql);
 
-	if (($query) || ($db_conn->ErrorNo() == 1032)) {
+	if (($db_conn->ErrorNo() == 0) || ($db_conn->ErrorNo() == 1032)) {
 		if (!$query->EOF) {
 			if ($col_name != '') {
 				$column = $query->fields[$col_name];
@@ -184,7 +184,7 @@
 	$db_conn->SetFetchMode(ADODB_FETCH_ASSOC);
 	$query = $db_conn->Execute($sql);
 
-	if (($query) || ($db_conn->ErrorNo() == 1032)) {
+	if (($db_conn->ErrorNo() == 0) || ($db_conn->ErrorNo() == 1032)) {
 		if (!$query->EOF) {
 			$fields = $query->fields;
 
@@ -222,7 +222,7 @@
 	$db_conn->SetFetchMode(ADODB_FETCH_ASSOC);
 	$query = $db_conn->Execute($sql);
 
-	if (($query) || ($db_conn->ErrorNo() == 1032)) {
+	if (($db_conn->ErrorNo() == 0) || ($db_conn->ErrorNo() == 1032)) {
 		while ((!$query->EOF) && ($query)) {
 			$data{sizeof($data)} = $query->fields;
 			$query->MoveNext();
diff -ruBbd cacti-0.8.7g/poller.php cacti-0.8.7g-patched/poller.php
--- cacti-0.8.7g/poller.php	2010-07-09 18:33:46.000000000 -0400
+++ cacti-0.8.7g-patched/poller.php	2010-08-31 20:31:22.000000000 -0400
@@ -109,7 +109,7 @@
 }
 
 /* record the start time */
-list($micro,$seconds) = split(" ", microtime());
+list($micro,$seconds) = explode(" ", microtime());
 $poller_start         = $seconds + $micro;
 $overhead_time = 0;
 
@@ -140,7 +140,7 @@
 							WHERE rrd_next_step<=0
 							GROUP BY host_id
 							ORDER BY host_id"), "host_id", "data_sources");
-	$poller_runs       = $cron_interval / $poller_interval;
+	$poller_runs       = intval($cron_interval / $poller_interval);
 
 	define("MAX_POLLER_RUNTIME", $poller_runs * $poller_interval - 2);
 }else{
@@ -211,10 +211,11 @@
 
 $poller_runs_completed = 0;
 $poller_items_total    = 0;
+$polling_hosts         = array_merge(array(0 => array("id" => "0")), db_fetch_assoc("SELECT id FROM host WHERE disabled='' ORDER BY id"));
 
 while ($poller_runs_completed < $poller_runs) {
 	/* record the start time for this loop */
-	list($micro,$seconds) = split(" ", microtime());
+	list($micro,$seconds) = explode(" ", microtime());
 	$loop_start = $seconds + $micro;
 
 	/* calculate overhead time */
@@ -222,8 +223,6 @@
 		$overhead_time = $loop_start - $poller_start;
 	}
 
-	$polling_hosts = array_merge(array(0 => array("id" => "0")), db_fetch_assoc("SELECT id FROM host WHERE disabled = '' ORDER BY id"));
-
 	/* initialize counters for script file handling */
 	$host_count = 1;
 
@@ -375,7 +374,7 @@
 
 				break;
 			}else {
-				if (read_config_option("log_verbosity") >= POLLER_VERBOSITY_MEDIUM) {
+				if (read_config_option("log_verbosity") >= POLLER_VERBOSITY_MEDIUM || $debug) {
 					print "Waiting on " . ($started_processes - $finished_processes) . " of " . $started_processes . " pollers.\n";
 				}
 
@@ -390,7 +389,7 @@
 
 					break;
 				}else{
-					sleep(1);
+					usleep(500);
 				}
 			}
 		}
@@ -427,28 +426,27 @@
 	$poller_runs_completed++;
 
 	/* record the start time for this loop */
-	list($micro,$seconds) = split(" ", microtime());
+	list($micro,$seconds) = explode(" ", microtime());
 	$loop_end = $seconds + $micro;
+	$loop_time = $loop_end - $loop_start;
 
-	if (($loop_end - $loop_start) < $poller_interval) {
+	if ($loop_time < $poller_interval) {
 		if ($poller_runs_completed == 1) {
-			$sleep_time = ($poller_interval - ($loop_end - $loop_start) - $overhead_time);
-		}else{
-			$sleep_time = ($poller_interval -  ($loop_end - $loop_start));
+			$sleep_time = $poller_interval - $loop_time - $overhead_time;
+		} else {
+			$sleep_time = $poller_interval - $loop_time;
 		}
 
 		/* log some nice debug information */
-		if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_DEBUG) {
-			echo "Loop  Time is: " . ($loop_end - $loop_start) . "\n";
-			echo "Sleep Time is: " . $sleep_time . "\n";
-			echo "Total Time is: " . ($loop_end - $poller_start) . "\n";
+		if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_DEBUG || $debug) {
+			echo "Loop  Time is: " . round($loop_time, 2) . "\n";
+			echo "Sleep Time is: " . round($sleep_time, 2) . "\n";
+			echo "Total Time is: " . round($loop_end - $poller_start, 2) . "\n";
  		}
 
 		/* sleep the appripriate amount of time */
 		if ($poller_runs_completed < $poller_runs) {
-			db_close();
 			usleep($sleep_time * 1000000);
-			db_connect_real($database_hostname, $database_username, $database_password, $database_default, $database_type, $database_port);
 		}
 	}else if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_MEDIUM || $debug) {
 		cacti_log("WARNING: Cacti Polling Cycle Exceeded Poller Interval by " . $loop_end-$loop_start-$poller_interval . " seconds", TRUE, "POLLER");
@@ -459,7 +457,7 @@
 	$hosts_per_process, $num_polling_items, $rrds_processed) {
 
 	/* take time and log performance data */
-	list($micro,$seconds) = split(" ", microtime());
+	list($micro,$seconds) = explode(" ", microtime());
 	$loop_end = $seconds + $micro;
 
 	$cacti_stats = sprintf(

