diff -urpN ../storm/stormexpense/stormexpense.module ./stormexpense/stormexpense.module
--- ../storm/stormexpense/stormexpense.module	2010-10-11 11:40:13.000000000 -0400
+++ ./stormexpense/stormexpense.module	2011-01-10 10:52:00.111106000 -0500
@@ -109,7 +109,7 @@ function stormexpense_access_sql($sql, $
 function stormexpense_storm_rewrite_where_sql($query, $primary_table, $account) {
   static $conds = array();
 
-  if ($conds[$primary_table][$account->uid]) {
+  if (isset($conds[$primary_table][$account->uid])) {
     return $conds[$primary_table][$account->uid];
   }
 
diff -urpN ../storm/storminvoice/storminvoice.module ./storminvoice/storminvoice.module
--- ../storm/storminvoice/storminvoice.module	2010-10-27 09:47:33.000000000 -0400
+++ ./storminvoice/storminvoice.module	2011-01-10 10:52:27.931119000 -0500
@@ -255,7 +255,7 @@ function storminvoice_access_sql($sql, $
 function storminvoice_storm_rewrite_where_sql($query, $primary_table, $account) {
   static $conds = array();
 
-  if ($conds[$primary_table][$account->uid]) {
+  if (isset($conds[$primary_table][$account->uid])) {
     return $conds[$primary_table][$account->uid];
   }
 
diff -urpN ../storm/stormknowledgebase/stormknowledgebase.module ./stormknowledgebase/stormknowledgebase.module
--- ../storm/stormknowledgebase/stormknowledgebase.module	2010-09-09 18:16:36.000000000 -0400
+++ ./stormknowledgebase/stormknowledgebase.module	2011-01-10 10:53:13.741103000 -0500
@@ -95,7 +95,7 @@ function stormknowledgebase_access_sql($
 function stormknowledgebase_storm_rewrite_where_sql($query, $primary_table, $account) {
   static $conds = array();
 
-  if ($conds[$primary_table][$account->uid]) {
+  if (isset($conds[$primary_table][$account->uid])) {
     return $conds[$primary_table][$account->uid];
   }
 
diff -urpN ../storm/stormnote/stormnote.module ./stormnote/stormnote.module
--- ../storm/stormnote/stormnote.module	2010-09-09 18:16:37.000000000 -0400
+++ ./stormnote/stormnote.module	2011-01-10 10:53:35.031099000 -0500
@@ -109,7 +109,7 @@ function stormnote_access_sql($sql, $whe
 function stormnote_storm_rewrite_where_sql($query, $primary_table, $account) {
   static $conds = array();
 
-  if ($conds[$primary_table][$account->uid]) {
+  if (isset($conds[$primary_table][$account->uid])) {
     return $conds[$primary_table][$account->uid];
   }
 
diff -urpN ../storm/stormorganization/stormorganization.module ./stormorganization/stormorganization.module
--- ../storm/stormorganization/stormorganization.module	2010-09-09 18:16:37.000000000 -0400
+++ ./stormorganization/stormorganization.module	2011-01-10 10:53:56.811120000 -0500
@@ -105,7 +105,7 @@ function stormorganization_access_sql($s
 function stormorganization_storm_rewrite_where_sql($query, $primary_table, $account) {
   static $conds = array();
 
-  if ($conds[$primary_table][$account->uid]) {
+  if (isset($conds[$primary_table][$account->uid])) {
     return $conds[$primary_table][$account->uid];
   }
 
diff -urpN ../storm/stormperson/stormperson.module ./stormperson/stormperson.module
--- ../storm/stormperson/stormperson.module	2010-09-09 18:16:37.000000000 -0400
+++ ./stormperson/stormperson.module	2011-01-10 11:29:50.191097000 -0500
@@ -20,18 +20,18 @@ function stormperson_help($path, $arg) {
 function stormperson_init() {
   if (function_exists('drupal_set_content')) {
     global $user;
-    if ($user->uid && !$user->stormorganization_nid || !$user->stormperson_nid) {
+    if (isset($user->uid) && (!isset($user->stormorganization_nid)) || (!isset($user->stormperson_nid))) {
       $r = db_query("SELECT nid, organization_nid FROM {stormperson} WHERE user_uid=%d", $user->uid);
-      if ($r) {
+      if ($r->num_rows > 0) {
         $a = db_fetch_object($r);
         $user->stormperson_nid = $a->nid;
         $user->stormorganization_nid = $a->organization_nid;
       }
     }
-    if (!$user->uid || !$user->stormperson_nid) {
+    if (!isset($user->uid) || !isset($user->stormperson_nid)) {
       $user->stormperson_nid = -1;
     }
-    if (!$user->uid || !$user->stormorganization_nid) {
+    if (!isset($user->uid) || !isset($user->stormorganization_nid)) {
       $user->stormorganization_nid = -1;
     }
   }
@@ -154,7 +154,7 @@ function stormperson_access_sql($sql, $w
 function stormperson_storm_rewrite_where_sql($query, $primary_table, $account) {
   static $conds = array();
 
-  if ($conds[$primary_table][$account->uid]) {
+  if (isset($conds[$primary_table][$account->uid])) {
     return $conds[$primary_table][$account->uid];
   }
 
@@ -521,7 +521,7 @@ function stormperson_user($type, &$edit,
 
 function _stormperson_user_load(&$account) {
   $r = db_query("SELECT nid, organization_nid FROM {stormperson} WHERE user_uid=%d", $account->uid);
-  if ($r) {
+  if ($r->num_rows > 0) {
     $a = db_fetch_object($r);
     $account->stormperson_nid = $a->nid;
     $account->stormorganization_nid = $a->organization_nid;
diff -urpN ../storm/stormproject/stormproject.module ./stormproject/stormproject.module
--- ../storm/stormproject/stormproject.module	2010-10-11 11:40:14.000000000 -0400
+++ ./stormproject/stormproject.module	2011-01-10 10:56:53.131100000 -0500
@@ -177,7 +177,7 @@ function stormproject_access_sql($sql, $
 function stormproject_storm_rewrite_where_sql($query, $primary_table, $account) {
   static $conds = array();
 
-  if ($conds[$primary_table][$account->uid]) {
+  if (isset($conds[$primary_table][$account->uid])) {
     return $conds[$primary_table][$account->uid];
   }
 
diff -urpN ../storm/stormtask/stormtask.module ./stormtask/stormtask.module
--- ../storm/stormtask/stormtask.module	2010-10-11 11:40:14.000000000 -0400
+++ ./stormtask/stormtask.module	2011-01-10 10:57:51.661099000 -0500
@@ -164,7 +164,7 @@ function stormtask_access_sql($sql, $whe
 function stormtask_storm_rewrite_where_sql($query, $primary_table, $account) {
   static $conds = array();
 
-  if ($conds[$primary_table][$account->uid]) {
+  if (isset($conds[$primary_table][$account->uid])) {
     return $conds[$primary_table][$account->uid];
   }
 
diff -urpN ../storm/stormteam/stormteam.module ./stormteam/stormteam.module
--- ../storm/stormteam/stormteam.module	2010-09-09 18:16:37.000000000 -0400
+++ ./stormteam/stormteam.module	2011-01-10 10:58:22.641106000 -0500
@@ -207,7 +207,7 @@ function stormteam_access_sql($sql, $whe
 function stormteam_storm_rewrite_where_sql($query, $primary_table, $account) {
   static $conds = array();
 
-  if ($conds[$primary_table][$account->uid]) {
+  if (isset($conds[$primary_table][$account->uid])) {
     return $conds[$primary_table][$account->uid];
   }
 
diff -urpN ../storm/stormteam/stormteam.test ./stormteam/stormteam.test
--- ../storm/stormteam/stormteam.test	1969-12-31 19:00:00.000000000 -0500
+++ ./stormteam/stormteam.test	2011-01-09 08:48:44.931106000 -0500
@@ -0,0 +1,30 @@
+<?php
+class StormteamTestCase extends DrupalWebTestCase {
+
+  public static function getInfo() {
+    return array(
+      'name' => t('Storm Team Functionality'),
+      'description' => t('Test the functionality of the Storm Team module'),
+      'group' => 'Storm',
+    );
+  }
+
+  public function setUp() {
+    parent::setUp('storm', 'stormattribute', 'stormorganization', 'stormperson', 'stormteam');
+  }
+
+  public function testStormteamCreate() {
+    // Create and login user
+    $user = $this->drupalCreateUser(array('Storm team: add', 'Storm team: view all', 'Storm person: add', 'Storm person: view all'));
+    $this->drupalLogin($user);
+
+    // Create a team
+    $team = array(
+      'title' => $this->randomName(32),
+    );
+
+    $this->drupalPost('node/add/stormteam', $team, t('Save'));
+
+    $this->assertText(t('Team @title has been created.', array('@title' => $team['title'])));;
+  }
+}

diff -urpN ../storm/stormticket/stormticket.module ./stormticket/stormticket.module
--- ../storm/stormticket/stormticket.module	2010-10-11 11:40:14.000000000 -0400
+++ ./stormticket/stormticket.module	2011-01-10 10:58:49.811097000 -0500
@@ -168,7 +168,7 @@ function stormticket_access_sql($sql, $w
 function stormticket_storm_rewrite_where_sql($query, $primary_table, $account) {
   static $conds = array();
 
-  if ($conds[$primary_table][$account->uid]) {
+  if (isset($conds[$primary_table][$account->uid])) {
     return $conds[$primary_table][$account->uid];
   }
 
diff -urpN ../storm/stormtimetracking/stormtimetracking.module ./stormtimetracking/stormtimetracking.module
--- ../storm/stormtimetracking/stormtimetracking.module	2010-10-11 11:40:14.000000000 -0400
+++ ./stormtimetracking/stormtimetracking.module	2011-01-10 10:59:39.881105000 -0500
@@ -110,7 +110,7 @@ function stormtimetracking_access_sql($s
 function stormtimetracking_storm_rewrite_where_sql($query, $primary_table, $account) {
   static $conds = array();
 
-  if ($conds[$primary_table][$account->uid]) {
+  if (isset($conds[$primary_table][$account->uid])) {
     return $conds[$primary_table][$account->uid];
   }
 
