diff --git a/simple_access.module b/simple_access.module
index 2383036..c2a756c 100644
--- a/simple_access.module
+++ b/simple_access.module
@@ -162,28 +162,46 @@ function simple_access_node_prepare($node) {
  * Implement hook_node_load().
  */
 function simple_access_node_load($nodes, $types) {
-  foreach ($nodes as $node) {
-    
-    if ($row = db_select('simple_access_owner', 'o')->fields('o', array('sa_view', 'sa_update', 'sa_delete'))->condition('nid', $node->nid)->execute()->fetchAssoc()) {
-      $node->simple_access_owner = $row;
-    }
-    else {
+
+  $nidList = array();
+  foreach ($nodes as $nid => $node) {
+    $nidList[]                    = $nid;
+    $node->simple_access          = array();
+    $node->simple_access_profiles = array();
+  }
+
+  $owners = db_select('simple_access_owner', 'o')
+    ->fields('o', array('nid', 'sa_view', 'sa_update', 'sa_delete'))
+    ->condition('nid', $nidList)
+    ->execute()
+    ->fetchAllAssoc('nid', PDO::FETCH_ASSOC);
+
+  $access = db_select('simple_access_node', 'na')
+    ->fields('na', array('nid', 'gid', 'sa_view', 'sa_update', 'sa_delete'))
+    ->condition('nid', $nidList)
+    ->execute()
+    ->fetchAll(PDO::FETCH_ASSOC);
+
+  $profiles = db_select('simple_access_profiles_node', 'pn')
+    ->fields('pn', array('nid', 'pid'))
+    ->condition('nid', $nidList)
+    ->execute()
+    ->fetchAll(PDO::FETCH_ASSOC);
+
+  foreach ($nodes as $nid => $node) {
+    if (isset($owners[$nid])) {
+      $node->simple_access_owner = $owners[$nid];
+    } else {
       $node->simple_access_owner = array('sa_view' => 0, 'sa_update' => 0, 'sa_delete' => 0);
     }
+  }
 
-    $node->simple_access = db_select('simple_access_node', 'na')
-      ->fields('na', array('gid', 'sa_view', 'sa_update', 'sa_delete'))
-      ->condition('nid', $node->nid)
-      ->execute()
-      ->fetchAllAssoc('gid', PDO::FETCH_ASSOC);
-
-    $node->simple_access_profiles = db_select('simple_access_profiles_node', 'pn')
-      ->fields('pn', array('pid'))
-      ->condition('nid', $node->nid)
-      ->execute()
-      ->fetchAllAssoc('pid', PDO::FETCH_ASSOC);
+  foreach ($access as $row) {
+    $nodes[$row['nid']]->simple_access[$row['gid']] = $row;
+  }
 
-    $nodes[$node->nid] = $node;
+  foreach ($profiles as $row) {
+    $nodes[$row['nid']]->simple_access_profiles_node[$row['pid']] = $row;
   }
 }
 
@@ -382,7 +400,7 @@ function simple_access_form_node_type_form_alter(&$form, &$form_state) {
 
   $tmp_form = simple_access_form((object)$default, TRUE);
 
-  $form['simple_access'] = $tmp_form['sa'];
+  $form['simple_access'] = $tmp_form['simple_access'];
   $form['simple_access']['simple_access']['owner']['#parents'] = array('simple_access', 'simple_access_owner');
   $form['simple_access']['#tree'] = TRUE;
 
@@ -632,11 +650,11 @@ function simple_access_group_select() {
     // return just groups for which user is a member
       $roles = array_keys($user->roles);
       $result = db_select('simple_access_groups', 'g')
-        ->fields('g', array('gid'))
-        ->innerJoin('simple_access_roles', 'r', 'g.gid = r.gid')
-        ->condition('rid', $roles, 'IN')
-        ->groupBy('gid')
-        ->execute();
+      ->fields('g', array('gid'));
+      $result->innerJoin('simple_access_roles', 'r', 'g.gid = r.gid');
+      $result->condition('rid', $roles, 'IN');
+      $result->groupBy('gid');
+      $result = $result->execute();
       while ($group = $result->fetchAssoc(PDO::FETCH_ASSOC)) {
         $groups[$group['gid']]['access'] = TRUE;
       }
@@ -1071,4 +1089,4 @@ function simple_access_group_load($gid) {
 
 function simple_access_profile_load($pid) {
   return simple_access_get_profiles($pid);
-}
\ No newline at end of file
+}
