diff --git a/template.php b/template.php
index e96d068..f235d41 100755
--- a/template.php
+++ b/template.php
@@ -175,81 +175,95 @@ function basic_preprocess_comment_wrapper(&$vars) {
  */ 
 
 function basic_preprocess_block(&$vars, $hook) {
-    $block = $vars['block'];
-
-    // special block classes
-    $classes = array('block');
-    $classes[] = basic_id_safe('block-' . $vars['block']->module);
-    $classes[] = basic_id_safe('block-' . $vars['block']->region);
-    $classes[] = basic_id_safe('block-id-' . $vars['block']->bid);
-    $classes[] = 'clearfix';
-    
-    // support for Skinr Module
-    if (module_exists('skinr')) {
-      $classes[] = $vars['skinr'];
+  $block = $vars['block'];
+
+  // special block classes
+  $classes = array('block');
+  $classes[] = basic_id_safe('block-' . $vars['block']->module);
+  $classes[] = basic_id_safe('block-' . $vars['block']->region);
+  $classes[] = basic_id_safe('block-id-' . $vars['block']->bid);
+  $classes[] = 'clearfix';
+  
+  // support for Skinr Module
+  if (module_exists('skinr')) {
+    $classes[] = $vars['skinr'];
+  }
+  
+  $vars['block_classes'] = implode(' ', $classes); // Concatenate with spaces
+
+  if (theme_get_setting('basic_block_editing') && user_access('administer blocks')) {
+    // Display 'edit block' for custom blocks.
+    if ($block->module == 'block') {
+      $edit_links[] = l('<span>' . t('edit block') . '</span>', 'admin/build/block/configure/' . $block->module . '/' . $block->delta,
+        array(
+          'attributes' => array(
+            'title' => t('edit the content of this block'),
+            'class' => 'block-edit',
+          ),
+          'query' => drupal_get_destination(),
+          'html' => TRUE,
+        )
+      );
     }
-    
-    $vars['block_classes'] = implode(' ', $classes); // Concatenate with spaces
-
-    if (theme_get_setting('basic_block_editing') && user_access('administer blocks')) {
-        // Display 'edit block' for custom blocks.
-        if ($block->module == 'block') {
-          $edit_links[] = l('<span>' . t('edit block') . '</span>', 'admin/build/block/configure/' . $block->module . '/' . $block->delta,
-            array(
-              'attributes' => array(
-                'title' => t('edit the content of this block'),
-                'class' => 'block-edit',
-              ),
-              'query' => drupal_get_destination(),
-              'html' => TRUE,
-            )
-          );
-        }
-        // Display 'configure' for other blocks.
-        else {
-          $edit_links[] = l('<span>' . t('configure') . '</span>', 'admin/build/block/configure/' . $block->module . '/' . $block->delta,
-            array(
-              'attributes' => array(
-                'title' => t('configure this block'),
-                'class' => 'block-config',
-              ),
-              'query' => drupal_get_destination(),
-              'html' => TRUE,
-            )
-          );
-        }
-        // Display 'edit menu' for Menu blocks.
-        if (($block->module == 'menu' || ($block->module == 'user' && $block->delta == 1)) && user_access('administer menu')) {
-          $menu_name = ($block->module == 'user') ? 'navigation' : $block->delta;
-          $edit_links[] = l('<span>' . t('edit menu') . '</span>', 'admin/build/menu-customize/' . $menu_name,
-            array(
-              'attributes' => array(
-                'title' => t('edit the menu that defines this block'),
-                'class' => 'block-edit-menu',
-              ),
-              'query' => drupal_get_destination(),
-              'html' => TRUE,
-            )
-          );
-        }
-        // Display 'edit menu' for Menu block blocks.
-        elseif ($block->module == 'menu_block' && user_access('administer menu')) {
-          list($menu_name, ) = split(':', variable_get("menu_block_{$block->delta}_parent", 'navigation:0'));
-          $edit_links[] = l('<span>' . t('edit menu') . '</span>', 'admin/build/menu-customize/' . $menu_name,
-            array(
-              'attributes' => array(
-                'title' => t('edit the menu that defines this block'),
-                'class' => 'block-edit-menu',
-              ),
-              'query' => drupal_get_destination(),
-              'html' => TRUE,
-            )
-          );
-        }
-        $vars['edit_links_array'] = $edit_links;
-        $vars['edit_links'] = '<div class="edit">' . implode(' ', $edit_links) . '</div>';
-      }
+    // Display 'configure' for other blocks.
+    else {
+      $edit_links[] = l('<span>' . t('configure') . '</span>', 'admin/build/block/configure/' . $block->module . '/' . $block->delta,
+        array(
+          'attributes' => array(
+            'title' => t('configure this block'),
+            'class' => 'block-config',
+          ),
+          'query' => drupal_get_destination(),
+          'html' => TRUE,
+        )
+      );
+    }
+    // Display 'edit menu' for Menu blocks.
+    if (($block->module == 'menu' || ($block->module == 'user' && $block->delta == 1)) && user_access('administer menu')) {
+      $menu_name = ($block->module == 'user') ? 'navigation' : $block->delta;
+      $edit_links[] = l('<span>' . t('edit menu') . '</span>', 'admin/build/menu-customize/' . $menu_name,
+        array(
+          'attributes' => array(
+            'title' => t('edit the menu that defines this block'),
+            'class' => 'block-edit-menu',
+          ),
+          'query' => drupal_get_destination(),
+          'html' => TRUE,
+        )
+      );
+    }
+    // Display 'edit menu' for Menu block blocks.
+    elseif ($block->module == 'menu_block' && user_access('administer menu')) {
+      list($menu_name, ) = split(':', variable_get("menu_block_{$block->delta}_parent", 'navigation:0'));
+      $edit_links[] = l('<span>' . t('edit menu') . '</span>', 'admin/build/menu-customize/' . $menu_name,
+        array(
+          'attributes' => array(
+            'title' => t('edit the menu that defines this block'),
+            'class' => 'block-edit-menu',
+          ),
+          'query' => drupal_get_destination(),
+          'html' => TRUE,
+        )
+      );
+    }
+    $vars['edit_links_array'] = $edit_links;
+    $vars['edit_links'] = '<div class="edit">' . implode(' ', $edit_links) . '</div>';
+  }
+
+  // Add first/last block classes
+  $first_last = "";
+  // If block id (count) is 1, it's first in region.
+  if ($vars['block_id'] == '1') {
+    $first_last = " first";
+    $vars['block_classes'] .= $first_last;
   }
+  // Count amount of blocks about to be rendered in that region.
+  $block_count = count(block_list($vars['block']->region));
+  if ($vars['block_id'] == $block_count) {
+    $first_last = " last";
+    $vars['block_classes'] .= $first_last;
+  }
+}
 
 /*
  * Override or insert PHPTemplate variables into the block templates.
@@ -423,4 +437,4 @@ function basic_breadcrumb($breadcrumb) {
   }
   // Otherwise, return an empty string.
   return '';
-}
\ No newline at end of file
+}
