diff --git a/flag.inc b/flag.inc
index 4535713..362fc26 100644
--- a/flag.inc
+++ b/flag.inc
@@ -39,7 +39,7 @@ function flag_flag_definitions() {
  * Returns a flag definition.
  */
 function flag_fetch_definition($content_type = NULL) {
-  static $cache;
+  $cache = &drupal_static(__FUNCTION__);
   if (!isset($cache)) {
     $cache = module_invoke_all('flag_definitions');
     if (!isset($cache['node'])) {
@@ -63,7 +63,7 @@ function flag_fetch_definition($content_type = NULL) {
  * Returns all flag types defined on the system.
  */
 function flag_get_types() {
-  static $types;
+  $types = &drupal_static(__FUNCTION__);
   if (!isset($types)) {
     $types = array_keys(flag_fetch_definition());
   }
diff --git a/flag.module b/flag.module
index 0ede96e..e65ac35 100644
--- a/flag.module
+++ b/flag.module
@@ -1180,7 +1180,7 @@ function flag_theme() {
  */
 function template_preprocess_flag(&$variables) {
   global $user;
-  static $initialized = array();
+  $initialized = &drupal_static(__FUNCTION__);
 
   // Some typing shotcuts:
   $flag =& $variables['flag'];
@@ -1315,7 +1315,7 @@ function _flag_link_type_fields() {
  *   An array of the structure [name] => [number of flags].
  */
 function flag_get_counts($content_type, $content_id, $reset = FALSE) {
-  static $counts;
+  $counts = &drupal_static(__FUNCTION__);
 
   if ($reset) {
     $counts = array();
@@ -1351,7 +1351,7 @@ function flag_get_counts($content_type, $content_id, $reset = FALSE) {
  *   Reset the internal cache and execute the SQL query another time.
  */
 function flag_get_flag_counts($flag_name, $reset = FALSE) {
-  static $counts;
+  $counts = &drupal_static(__FUNCTION__);
 
   if ($reset) {
     $counts = array();
@@ -1410,7 +1410,7 @@ function flag_get_flag($name = NULL, $fid = NULL) {
  *   An array of the structure [fid] = flag_object.
  */
 function flag_get_flags($content_type = NULL, $content_subtype = NULL, $account = NULL, $reset = FALSE) {
-  static $flags;
+  $flags = &drupal_static(__FUNCTION__);
 
   // Retrieve a list of all flags, regardless of the parameters.
   if (!isset($flags) || $reset) {
@@ -1623,7 +1623,7 @@ function flag_get_content_id($fcid) {
  *
  */
 function flag_get_user_flags($content_type, $content_id = NULL, $uid = NULL, $sid = NULL, $reset = FALSE) {
-  static $flagged_content;
+  $flagged_content = &drupal_static(__FUNCTION__);
 
   if ($reset) {
     $flagged_content = array();
@@ -1697,7 +1697,7 @@ function flag_get_user_flags($content_type, $content_id = NULL, $uid = NULL, $si
  *   a flag name is specified, only the information for that flag is returned.
  */
 function flag_get_content_flags($content_type, $content_id, $flag_name = NULL, $reset = FALSE) {
-  static $content_flags;
+  $content_flags = &drupal_static(__FUNCTION__);
 
   if (!isset($content_flags[$content_type][$content_id]) || $reset) {
     $flag_names = _flag_get_flag_names();
@@ -1749,7 +1749,7 @@ function flag_create_link($flag_name, $content_id) {
  * Return an array of link types provided by modules.
  */
 function flag_get_link_types($reset = FALSE) {
-  static $link_types;
+  $link_types = &drupal_static(__FUNCTION__);
 
   if (!isset($link_types) || $reset) {
     $link_types = array();
@@ -1796,7 +1796,7 @@ function flag_check_token($token, $content_id) {
  * SID in case the user logs in during this request.
  */
 function flag_set_sid($uid = NULL) {
-  static $sids = array();
+  $sids = &drupal_static(__FUNCTION__);
 
   if (!isset($uid)) {
     $uid = $GLOBALS['user']->uid;
diff --git a/flag_actions.module b/flag_actions.module
index 6a20555..98158de 100644
--- a/flag_actions.module
+++ b/flag_actions.module
@@ -76,7 +76,7 @@ function flag_actions_get_action($aid) {
 }
 
 function flag_actions_get_actions($flag_name = NULL, $reset = FALSE) {
-  static $flag_actions;
+  $flag_actions = &drupal_static(__FUNCTION__);
   module_load_include('inc', 'flag', 'includes/flag.actions');
 
   // Get a list of all possible actions defined by modules.
diff --git a/includes/flag.views.inc b/includes/flag.views.inc
index 02fa5bb..42e7f44 100644
--- a/includes/flag.views.inc
+++ b/includes/flag.views.inc
@@ -246,7 +246,7 @@ function flag_views_flag_config_form($form_type, $content_type, $current_flag) {
  * Helper function that gets the first defined flag and returns its name.
  */
 function flag_views_flag_default($content_type) {
-  static $default_flag = array();
+  $default_flag = &drupal_static(__FUNCTION__);
 
   if (!array_key_exists($content_type, $default_flag)) {
     $flag = array_shift(flag_get_flags($content_type));
