diff --git a/transforms01/adl2controllerclasses.xslt b/transforms01/adl2controllerclasses.xslt
index 2e9de19..beac2ae 100755
--- a/transforms01/adl2controllerclasses.xslt
+++ b/transforms01/adl2controllerclasses.xslt
@@ -9,8 +9,8 @@
     Transform ADL into (partial) controller classes
     
     $Author: sb $
-    $Revision: 1.22 $
-    $Date: 2008-04-18 09:27:29 $
+    $Revision: 1.23 $
+    $Date: 2008-05-08 17:26:44 $
   -->
 
   
+                    if ( index.Equals( itemId))
+                    {
+                      found = true;
+                      break;
+                    }
+                  }
+          
+                  if ( ! found)
+                  {
+                    record..Remove( item);
+                  }
+                } /* foreach ( string index... */
+
+                /* then add any on the included list which are not already members */
                 foreach ( string index in )
                 {
-                  
-                  if ( index.Equals( itemId))
-                  {
-                    found = true;
-                  }
-                }
-          
-                if ( ! found)
-                {
-                  record..Remove( item);
-                }
-              }
-
-              /* then add any on the included list which are not already members */
-              foreach ( string index in )
-              {
                 
-                 item = 
-                  hibernator.CreateCriteria(typeof())
-                    .Add(Expression.Eq("Id", index))
-                    .UniqueResult<.>();
+                   item = 
+                    hibernator.CreateCriteria(typeof())
+                      .Add(Expression.Eq("Id", index))
+                      .UniqueResult<.>();
               
-                if ( ! record..Contains( item))
-                {
-                  record..Add( item);
-                }
-              }
-            }
+                  if ( ! record..Contains( item))
+                  {
+                    record..Add( item);
+                  }
+                } /* foreach ( string index... */
+              } /* if ( Form.GetValues( "") != null) */
             
 
-            /* write the record to the database, in order to guarantee we have a valid key */
-            hibernator.Save(record);
-            hibernator.Flush();
+              /* write the record to the database, in order to guarantee we have a valid key */
+              hibernator.Save(record);
+              hibernator.Flush();
+              tx.Commit();
         
-            messages.Add( "Record saved successfully");
-          }
-          catch ( DataSuitabilityException dse)
-          {
-            AddError( dse.Message);
-          }
-          catch ( ApplicationException axe)
-          {
-            AddError( axe.Message);
+              messages.Add( "Record saved successfully");
+            } /* try actually commit */
+            catch ( Exception any) {
+              tx.Rollback();
+              messages.Add( "Record not saved");
+              throw any;
+            }
+          } /* if ( record != null) */
+          else {
+            throw new ApplicationException( String.Format( "No record of type  with the key values supplied was found"));
           }
+        } /* try */
+        catch ( DataSuitabilityException dse)
+        {
+          AddError( dse);
+        }
+        catch ( ApplicationException axe)
+        {
+          AddError( axe.Message);
+        }
 
-          PropertyBag["messages"] = messages;
-          PropertyBag["instance"] = record;    
+        PropertyBag["messages"] = messages;
+        PropertyBag["instance"] = record;    
                
-          PropertyBag["username"] = Session[ NHibernateHelper.USERTOKEN];
+        PropertyBag["username"] = Session[ NHibernateHelper.USERTOKEN];
             
         
-          if ( ! AssertNoErrors())
-          {
-            /* the session may be polluted; create a new session */
-            NHibernateHelper.CloseSession();
-            hibernator = NHibernateHelper.GetCurrentSession(
-        Session[ NHibernateHelper.USERTOKEN],
-        Session[NHibernateHelper.PASSTOKEN]
-      );
-          }
-
-            
-              
-            
-          RenderViewWithFailover("", 
-              "");
-        }
-        else
+        if ( HasNoErrors())
         {
-          throw new DataRequiredException( "Record not found");
-        }
+          /* the session may be polluted; create a new session */
+          NHibernateHelper.CloseSession();
+          hibernator = NHibernateHelper.GetCurrentSession(
+            Session[ NHibernateHelper.USERTOKEN],
+            Session[NHibernateHelper.PASSTOKEN]
+      );
+
+		  
+			  
+			  
+		  
+
+		}
+		  
+            
+          
+        RenderViewWithFailover("", 
+              "");
       }
       
 
@@ -436,7 +460,8 @@ namespace  {
         if ( "true".Equals( reallydelete))
         {
         
-          
+			
+			
         
 
           if ( record != null)
@@ -486,7 +511,7 @@ namespace  {
           NHibernateHelper.GetCurrentSession( Session[ NHibernateHelper.USERTOKEN], 
                                               Session[NHibernateHelper.PASSTOKEN]);
         IList<> instances = 
-          hibernator.CreateCriteria(typeof())
+          hibernator.CreateCriteria(typeof())
             
           .List<>();
 
@@ -515,16 +540,41 @@ namespace  {
       );
         }
 
+      
+        
+          
+            
+          
+        
+        
+          
+            
+          
+        
+      
     
 
-    
-    
-        
-    
-      ""
-    
+	
+		
+			
+		
+	
 
-    
+	
+		
+			
+		
+	
+
+
+	
+	
+
+	
+		""
+	
+
+	
       
+	
+	
+		
+
+		
+			
+				
+			
+		
+
+		
+			
+				
+			
+			
+				/*  should be distinct: check that it is */
+				matches =
+					hibernator.CreateCriteria(typeof())
+				
+					
+						.Add(Expression.Eq("", Form[""]))
+					
+					
+						.Add(Expression.Eq("", Int32.Parse( Form[""])))
+					
+					
+						.Add(Expression.Eq("",
+						
+							
+							
+						))
+					
+					
+						
+							ADL: ERROR: don't yet know how to do distinctness checks for properties 
+							with base type 
+						
+					
+				
+				
+					.Add(Expression.Not(Expression.Eq("",
+						
+							
+								
+								
+								
+							
+						
+						
+							Int32.Parse( Form[""])
+						
+						
+							Form[""]
+						
+					)))
+				
+					.List<>();
+
+				if ( matches.Count > 0)
+				{
+					throw new
+						DataNotDistinctException(
+							String.Format("There is already a {0} with the {1} '{2}'",
+								"", "", Form[""]));
+				}
+			
+		
+	
+
+
+	
   
     
     
@@ -876,11 +997,15 @@ namespace  {
   declared) called 'record' -->
   
     
-       record = null;  
-
+		
         /* check whether values for all key slots have been passed in; if so, we're probably dealing with an
          * existing record */
+    
+				/* the instance (record) of type  we're dealing with */
+				 record = null;  
+				/* whether we have valid values for all the key fields */
         bool allkeys = true;
+		
     
         if ( String.IsNullOrEmpty( Form[""])) {
           allkeys = false;
@@ -893,7 +1018,6 @@ namespace  {
 
         if ( allkeys){
           /* it's (probably) existing, retrieve it */
-
           record = hibernator.CreateCriteria(typeof())