--- nodeasblock.module	2009-08-25 20:05:41.000000000 -0700
+++ nodeasblock.module.new	2009-08-25 20:08:56.000000000 -0700
@@ -149,6 +149,16 @@ function _nodeasblock_node_form(&$form) 
   
   if (isset($node->nid)) {
     $block = db_fetch_array(db_query("SELECT * FROM {blocks} WHERE module = '%s' AND delta = '%s' AND theme = '%s'", 'nodeasblock', $node->nid, $theme));
+  	if(!is_array($block)) {
+	  	$block = array(
+	      'status' => 1, 
+	      'roles' => array(),
+	      'region' => variable_get('nodeasblock_default_region_'. $node->type, system_default_region($theme)),
+	      'weight' => variable_get('nodeasblock_default_weight_'. $node->type, 0),
+	      'custom' => 0, 'visibility' => 0, 
+	      'pages' => ''
+    	);
+  	}
   }
   else {
     $block = array(
@@ -266,6 +276,8 @@ function nodeasblock_nodeapi(&$node, $op
           db_query('INSERT INTO {nodeasblock} VALUES (%d)', $node->nid);
           drupal_set_message(t('The block configuration has been saved.'));
           nodeasblock_save_block($node);
+        } else {
+        	db_query("DELETE FROM {blocks} WHERE module = 'nodeasblock' AND delta = '%s'", $node->nid);
         }
       }
       break;
