diff --git flag.module flag.module
index edebd07..7ac7f73 100644
--- flag.module
+++ flag.module
@@ -797,17 +797,17 @@ function flag_flag_access_multiple($flag, $content_ids, $account) {
  *
  * @param $fid
  *   The flag object.
- * @param $uid
- *   The user ID on behalf the trimming will occur.
+ * @param $account
+ *   The user object on behalf the trimming will occur.
  * @param $cutoff_size
  *   The number of flaggings allowed. Any flaggings beyond that will be trimmed.
  */
-function flag_trim_flag($flag, $uid, $cutoff_size) {
-  $result = db_query("SELECT * FROM {flag_content} WHERE fid = %d AND (uid = %d OR uid = 0) ORDER BY timestamp DESC", $flag->fid, $uid);
+function flag_trim_flag($flag, $account, $cutoff_size) {
+  $result = db_query("SELECT * FROM {flag_content} WHERE fid = %d AND (uid = %d OR uid = 0) ORDER BY timestamp DESC", $flag->fid, $account->uid);
   $i = 1;
   while ($row = db_fetch_object($result)) {
     if ($i++ > $cutoff_size) {
-      flag('unflag', $flag->name, $row->content_id, $uid);
+      flag('unflag', $flag->name, $row->content_id, $account);
     }
   }
 }
diff --git includes/flag.rules.inc includes/flag.rules.inc
index 96da6fc..8ffdb2b 100644
--- includes/flag.rules.inc
+++ includes/flag.rules.inc
@@ -45,7 +45,7 @@ class flag_rules_data_type extends rules_data_type {
   }
 
   /**
-   * Returns radios for selecting a flag of the type given in 
+   * Returns radios for selecting a flag of the type given in
    * $info['flag_type'].
    */
   function get_default_input_form($info, $value) {
@@ -82,7 +82,7 @@ function flag_rules_event_info() {
 
   $flags = flag_get_flags();
   foreach ($flags as $flag) {
-    
+
     $arguments = array(
       // First, define ubiquitous arguments.
       'flag' => array(
@@ -165,7 +165,7 @@ function flag_rules_action_info() {
     $flag = flag_create_handler($type);
     if ($flag->rules_get_element_argument_definition()) {
       $args += array('object' => $flag->rules_get_element_argument_definition());
-      
+
       $items += array(
         'flag_rules_action_flag_'. $type => array(
           'label' => t('Flag a @type', array('@type' => $type)),
@@ -217,7 +217,7 @@ function flag_rules_action_unflag($flag, $object, $flagging_user, $settings) {
  * Base action implementation: Trim flag.
  */
 function flag_rules_action_trim($flag, $flagging_user, $cutoff_size, $settings) {
-  flag_trim_flag($flag, $flagging_user->uid, $cutoff_size);
+  flag_trim_flag($flag, $flagging_user, $cutoff_size);
 }
 
 /**
@@ -236,7 +236,7 @@ function flag_rules_condition_info() {
     $flag = flag_create_handler($type);
     if ($flag->rules_get_element_argument_definition()) {
       $args += array('object' => $flag->rules_get_element_argument_definition());
-  
+
       $items += array(
         'flag_rules_condition_threshold_'. $type => array(
           'label' => drupal_ucfirst(t('@type has flagging count', array('@type' => $type))),
