diff --git a/tconfpy.py b/tconfpy.py
index 7c0cd67..e785498 100755
--- a/tconfpy.py
+++ b/tconfpy.py
@@ -6,7 +6,7 @@
 # Program Information
 
 PROGNAME = "tconfpy"
-RCSID = "$Id: tconfpy.py,v 1.112 2004/03/14 04:43:53 tundra Exp $"
+RCSID = "$Id: tconfpy.py,v 1.113 2004/03/14 09:04:52 tundra Exp $"
 VERSION = RCSID.split()[2]
 
 # Copyright Information
@@ -67,7 +67,7 @@
 PTR         = "   --->   "           # Textual pointer for debug output
 
 
-# Reserved Symbols
+# Special And Reserved Symbols
 
 HASH        = r'#'
 COMMENT     = HASH         # Comment introducer character
@@ -78,15 +78,15 @@
 EQUIV       = r"=="        # Used in conditional tests
 NOTEQUIV    = r"!="        # Used in conditional tests
 
-Reserved    = ["DELIML", "DELIMR", "DOLLAR", "EQUAL", "EQUIV", "NOTEQUIV",
-               "HASH", "INCLUDE", "ENDIF", "IF"]
-
 # Control and conditional symbols
 
 INCLUDE     = ".include"
 ENDIF       = ".endif"
 IF          = ".if"
 
+Reserved    = ["DELIML", "DELIMR", "DOLLAR", "EQUAL", "EQUIV", "NOTEQUIV",
+               "HASH", "INCLUDE", "ENDIF", "IF"]
+
 
 # Regular Expressions
 
@@ -99,6 +99,10 @@
 ###########
 
 
+TRUE   = str(True)
+FALSE  = str(False)
+
+
 #----------------------------------------------------------#
 #          Global Variables & Data Structures              #
 #----------------------------------------------------------#
@@ -193,13 +197,11 @@
 
 eERROR      = "ERROR"
 
+eBADCOND    = FILENUM + " Badly Formed Conditional Expression:  '%s'"
 eCONFOPEN   = "Cannot Open The File '%s'"
-eENDIFEXTRA = FILENUM + " " + ENDIF + " Without Matching Condition"
-
-
-###########
-# Prompts
-###########
+eENDIFEXTRA = FILENUM + " '" + ENDIF + "' Without Matching Condition"
+eENDIFMISS  = FILENUM + " Missing %d '" + ENDIF + "' Statement(s)"
+eVARUNDEF   = FILENUM + " " + "Attempt To Reference Undefined Variable '%s'"
 
 
 ###########
@@ -208,7 +210,7 @@
 
 wWARNING     = "WARNING"
 
-wENDIFBAD    = FILENUM + " Text After " + ENDIF + " Ignored"
+wTRAILING    = FILENUM + " Trailing Text After '%s' Statement Ignored"
 
 
 #--------------------------- Code Begins Here ---------------------------------#
@@ -349,7 +351,6 @@
 # End of 'ConditionLine()'
 
 
-
 ##########
 # Dereference Variables
 ##########
@@ -358,13 +359,19 @@
 
     # Find all symbols refrences and replace w/sym table entry if present
 
+    ref_ok = True
     for var in VarRef.findall(line):
 
         sym = var[1:-1]   # Strip delimiters
         if sym in SymTable:
             line = line.replace(var, str(SymTable[sym][SYM_VALUE]))
 
-    return line
+        # Reference to undefined variable
+        else:
+            ErrorMsg(eVARUNDEF % (cfgfile, linenum, sym))
+            ref_ok = False
+            
+    return line, ref_ok
 
 # End of 'DerefVar()'
 
@@ -401,6 +408,12 @@
 
         ErrorMsg(eCONFOPEN % cfgfile)  # Record the error
 
+    # Make sure we had all condition blocks balanced with matching '.endif'
+
+    finalcond = len(CondStack)
+    if finalcond != 1:
+        ErrorMsg(eENDIFMISS % (cfgfile, linenum, finalcond-1))
+
 # End of 'ParseFile()'
 
 
@@ -432,7 +445,7 @@
 
             # This should be the only thing on the line
             if line != ENDIF:
-                WarningMsg(wENDIFBAD % (cfgfile, linenum))
+                WarningMsg(wTRAILING % (cfgfile, linenum, ENDIF))
 
             # Remove one level of nesting
             CondStack.pop()
@@ -472,25 +485,45 @@
         if line.startswith(IF):
             line = line.split(IF)[1].strip()
 
-            # Handle .if string == string form
+            # Handle Equality Form: ".if string == string"
             if line.count(EQUIV):
                 pass
 
-            # Handle .if string != string form
+            # Handle Inequality Form: ".if string != string"
             elif line.count(NOTEQUIV):
                 pass
 
-            # Handle .if string
-            # FIXXXXXXX THIS TO CHECK FOR CORRECT FORM FIRST
+            # Handle Existential Form: ".if string"
             else:
-                line = DerefVar(line, cfgfile, linenum)
 
-                # See if all the variable references were resolved
+                # Must be in form: ".if [var]" - trailing garbage ignored
 
-                if not VarRef.match(line):
-                    CondStack.append(True)
+                chk = VarRef.findall(line)
+                if line[0] == DELIML and len(chk) > 0:
+
+                    # Warn if there was trailing garbage
+                    if len(line) != len(chk[0]):
+                        WarningMsg(wTRAILING % (cfgfile, linenum, IF + " " + chk[0]))
+
+                    # And condition the line to only contain the variable reference
+                    line = chk[0]
+
+                    # Now see if the variable resolved and set state accordingly
+
+                    line, ref_ok = DerefVar(line, cfgfile, linenum)
+                    if ref_ok:
+                        line = TRUE
+                        CondStack.append(True)
+                    else:
+                        line = FALSE
+                        CondStack.append(False)                    
+
+                # Bogus conditional syntax
                 else:
-                    CondStack.append(False)
+                    ErrorMsg(eBADCOND % (cfgfile, linenum, orig))
+
+
+        line, ref_ok = DerefVar(line, cfgfile, linenum)
 
             
 
@@ -504,7 +537,7 @@
         if not line:
             line = dBLANKLINE
 
-        DebugMsg(dPARSEDLINE %(cfgfile, linenum, orig, line))
+        DebugMsg(dPARSEDLINE % (cfgfile, linenum, orig, line))
 
 # End of 'ParseLine'