diff -ruBbd cacti-0.8.6b/lib/graph_variables.php cacti-0.8.6b-new/lib/graph_variables.php
--- cacti-0.8.6b/lib/graph_variables.php	2004-12-01 19:50:28.000000000 -0500
+++ cacti-0.8.6b-new/lib/graph_variables.php	2004-12-01 19:50:45.000000000 -0500
@@ -111,9 +111,6 @@
 	return $return_array;
 }
 
-/* this variable is used as a cache to prevent extra calls to ninety_fifth_percentile() */
-$ninety_fifth_cache = array();
-
 /* variable_ninety_fifth_percentile - given a 95th percentile variable, calculate the 95th percentile
      and format it for display on the graph
    @arg $regexp_match_array - the array that contains each argument in the 95th percentile variable. it
@@ -133,19 +130,17 @@
      varies depending on the RRA in use
    @returns - a string containg the 95th percentile suitable for placing on the graph */
 function variable_ninety_fifth_percentile(&$regexp_match_array, &$graph_item, &$graph_items, $graph_start, $graph_end) {
-	global $ninety_fifth_cache, $graph_item_types;
+	global $graph_item_types;
 
 	if (sizeof($regexp_match_array) == 0) {
 		return 0;
 	}
 
 	if (($regexp_match_array[3] == "current") || ($regexp_match_array[3] == "max")) {
-		if (!isset($ninety_fifth_cache{$graph_item["local_data_id"]})) {
 			$ninety_fifth_cache{$graph_item["local_data_id"]} = ninety_fifth_percentile($graph_item["local_data_id"], $graph_start, $graph_end);
-		}
 	}elseif ($regexp_match_array[3] == "total") {
 		for ($t=0;($t<count($graph_items));$t++) {
-			if ((!isset($ninety_fifth_cache{$graph_items[$t]["local_data_id"]})) && (!empty($graph_items[$t]["local_data_id"]))) {
+			if (!empty($graph_items[$t]["local_data_id"])) {
 				$ninety_fifth_cache{$graph_items[$t]["local_data_id"]} = ninety_fifth_percentile($graph_items[$t]["local_data_id"], $graph_start, $graph_end);
 			}
 		}
@@ -185,9 +180,6 @@
 	return round($ninety_fifth, $round_to);
 }
 
-/* this variable is used as a cache to prevent extra calls to bandwidth_summation() */
-$summation_cache = array();
-
 /* variable_bandwidth_summation - given a bandwidth summation variable, calculate the summation
      and format it for display on the graph
    @arg $regexp_match_array - the array that contains each argument in the bandwidth summation variable. it
@@ -210,7 +202,7 @@
    @arg $ds_step - how many seconds each period represents
    @returns - a string containg the bandwidth summation suitable for placing on the graph */
 function variable_bandwidth_summation(&$regexp_match_array, &$graph_item, &$graph_items, $graph_start, $graph_end, $rra_step, $ds_step) {
-	global $summation_cache, $graph_item_types;
+	global $graph_item_types;
 
 	if (sizeof($regexp_match_array) == 0) {
 		return 0;
@@ -223,21 +215,21 @@
 	}
 
 	if ($regexp_match_array[2] == "current") {
-		if (!isset($summation_cache{$graph_item["local_data_id"]})) {
 			$summation_cache{$graph_item["local_data_id"]} = bandwidth_summation($graph_item["local_data_id"], $summation_timespan_start, $graph_end, $rra_step, $ds_step);
-		}
 	}elseif ($regexp_match_array[2] == "total") {
 		for ($t=0;($t<count($graph_items));$t++) {
-			if ((!isset($summation_cache{$graph_items[$t]["local_data_id"]})) && (!empty($graph_items[$t]["local_data_id"]))) {
+			if (!empty($graph_items[$t]["local_data_id"])) {
 				$summation_cache{$graph_items[$t]["local_data_id"]} = bandwidth_summation($graph_items[$t]["local_data_id"], $summation_timespan_start, $graph_end, $rra_step, $ds_step);
 			}
 		}
+	}elseif ($regexp_match_array[2] == "atomic") {
+		$summation_cache{$graph_item["local_data_id"]} = bandwidth_summation($graph_item["local_data_id"], $summation_timespan_start, $graph_end, $rra_step, 1);
 	}
 
 	$summation = 0;
 
 	/* format the output according to args passed to the variable */
-	if ($regexp_match_array[2] == "current") {
+	if (($regexp_match_array[2] == "current") || ($regexp_match_array[2] == "atomic")) {
 		$summation = $summation_cache{$graph_item["local_data_id"]}{$graph_item["data_source_name"]};
 	}elseif ($regexp_match_array[2] == "total") {
 		for ($t=0;($t<count($graph_items));$t++) {
diff -ruBbd cacti-0.8.6b/lib/rrd.php cacti-0.8.6b-new/lib/rrd.php
--- cacti-0.8.6b/lib/rrd.php	2004-12-01 19:50:28.000000000 -0500
+++ cacti-0.8.6b-new/lib/rrd.php	2004-12-01 19:50:48.000000000 -0500
@@ -25,6 +25,7 @@
 */
 
 define("RRD_NL", " \\\n");
+define("MAX_FETCH_CACHE_SIZE", 5);
 
 function escape_command($command) {
 	return ereg_replace("(\\\$|`)", "", $command);
@@ -305,6 +306,8 @@
 	}
 }
 
+$rrd_fetch_cache = array();
+
 /* rrdtool_function_fetch - given a data source, return all of its data in an array
    @arg $local_data_id - the data source to fetch data for
    @arg $start_time - the start time to use for the data calculation. this value can
@@ -316,10 +319,20 @@
 	 by each data source item. the maximum of all data source items is included in
 	 an item called 'ninety_fifth_percentile_maximum' */
 function &rrdtool_function_fetch($local_data_id, $start_time, $end_time, $resolution = 0) {
+	global $rrd_fetch_cache;
+
 	if (empty($local_data_id)) {
 		return;
 	}
 
+	/* the cache hash is used to identify unique items in the cache */
+	$current_hash_cache = md5($local_data_id . $start_time . $end_time . $resolution);
+
+	/* return the cached entry if available */
+	if (isset($rrd_fetch_cache[$current_hash_cache])) {
+		return $rrd_fetch_cache[$current_hash_cache];
+	}
+
 	$regexps = array();
 	$fetch_array = array();
 
@@ -337,7 +350,7 @@
 	$line_one = substr($output, 0, strpos($output, "\n"));
 
 	/* loop through each data source in this .rrd file ... */
-	if (preg_match_all("/\w+/", $line_one, $data_source_names)) {
+	if (preg_match_all("/\S+/", $line_one, $data_source_names)) {
 		/* version 1.0.49 changed the output slightly */
 		if (preg_match("/^timestamp/", $line_one)) {
 			array_shift($data_source_names[0]);
@@ -398,6 +411,16 @@
 		}
 	}
 
+	/* clear the cache if it gets too big */
+	if (sizeof($rrd_fetch_cache) >= MAX_FETCH_CACHE_SIZE) {
+		$rrd_fetch_cache = array();
+	}
+
+	/* update the cache */
+	if (MAX_FETCH_CACHE_SIZE > 0) {
+		$rrd_fetch_cache[$current_hash_cache] = $fetch_array;
+	}
+
 	return $fetch_array;
 }
