diff --git a/tconfpy.py b/tconfpy.py
index aa822dd..b82859b 100755
--- a/tconfpy.py
+++ b/tconfpy.py
@@ -6,7 +6,7 @@
 # Program Information
 
 PROGNAME = "tconfpy"
-RCSID = "$Id: tconfpy.py,v 1.117 2004/03/15 00:19:56 tundra Exp $"
+RCSID = "$Id: tconfpy.py,v 1.118 2004/03/16 03:18:19 tundra Exp $"
 VERSION = RCSID.split()[2]
 
 # Copyright Information
@@ -206,11 +206,15 @@
 ###########
 
 eERROR      = "ERROR"
+eSYNTAX     = "Incorrect '%s' Syntax"
 
-eBADCOND    = FILENUM + " Bad Conditional Expression - %s:  '%s'"
+eBADEXPR    = FILENUM + " Bad Expression - %s:  '%s'"
 eCONFOPEN   = "Cannot Open The File '%s'"
 eENDIFEXTRA = FILENUM + " '" + ENDIF + "' Without Matching Condition"
+eENDIFBAD   = eSYNTAX % ENDIF
 eENDIFMISS  = FILENUM + " Missing %d '" + ENDIF + "' Statement(s)"
+eIFBAD      = eSYNTAX % IF
+eINCLBAD    = eSYNTAX % INCLUDE
 eNOVARREF   = "Must Have At Least One Variable Reference"
 eVARUNDEF   = FILENUM + " " + "Attempt To Reference Undefined Variable '%s'"
 
@@ -456,16 +460,22 @@
     # Only attempt on non-blank lines
     if line:
 
+        # Get first token on the line
+        FIRSTTOK = line.split()[0]
+
         #####
         # .endif Processing - Must be done before state check
-        #                     because .endif can change state
+        #                     because .endif can change parser state
         #####
-        
 
         if line.startswith(ENDIF):
 
+            # Check for space after conditional
+            if line.split()[0] != ENDIF:
+                ErrorMsg(eBADEXPR % (cfgfile, linenum, eENDIFBAD, orig))
+
             # This should be the only thing on the line
-            if line != ENDIF:
+            elif line != ENDIF:
                 WarningMsg(wTRAILING % (cfgfile, linenum, ENDIF))
 
             # Remove one level of nesting
@@ -490,7 +500,13 @@
         #####
 
         if line.startswith(INCLUDE):
-            ParseFile(line.split(INCLUDE)[1].strip())
+
+            # Make sure a space follows the directive
+            if line.split()[0] != INCLUDE:
+                ErrorMsg(eBADEXPR % (cfgfile, linenum, eINCLBAD, orig))
+
+            else:
+                    ParseFile(line.split(INCLUDE)[1].strip())
 
 
         #####
@@ -508,28 +524,25 @@
         #
         #####
 
-        if line.startswith(IF):
+        # Is it any of the IF forms?
 
-            # Since all conditional lines start with IF,
-            # test for this case last - i.e. test the for
-            # longest tokens first.
+        if FIRSTTOK.startswith(IF):
 
+            IFTYPE = FIRSTTOK
+            
             #####
             # Existential Conditionals
             #####
 
-            if line.startswith(IFALL) or line.startswith(IFANY) or line.startswith(IFNONE):
+            if IFTYPE in (IFALL, IFANY, IFNONE):
 
-                if line.startswith(IFALL):
-                    IFTYPE = IFALL
+                if IFTYPE == IFALL:
                     line = line.split(IFALL)[1].strip()
 
-                elif line.startswith(IFANY):
-                    IFTYPE = IFANY
+                elif IFTYPE == IFANY:
                     line = line.split(IFANY)[1].strip()
 
                 else:
-                    IFTYPE = IFNONE
                     line = line.split(IFNONE)[1].strip()
 
                 # There must be at least one var reference in the condition
@@ -539,11 +552,12 @@
 
                     # Only variable references are significant - warn on other text.
 
-                    varlen = 0
+                    # Strip out variable references and see if anything
+                    # other than whitespace is left.
+                    
                     plain = line
                     for v in vars:
-                        varlen += len(v)
-                        plain.replace(v, "")
+                        plain=plain.replace(v, "")
 
                     if len(plain.strip()):
                         WarningMsg(wEXTRATEXT % (cfgfile, linenum, IFTYPE))
@@ -573,13 +587,14 @@
 
                 # Bogus conditional syntax
                 else:
-                    ErrorMsg(eBADCOND % (cfgfile, linenum, eNOVARREF, orig))
+                    ErrorMsg(eBADEXPR % (cfgfile, linenum, eNOVARREF, orig))
 
             #####
             # (In)Equality Conditionals
             #####
           
-            else:
+            # Check for IF followed by mandatory whitespace
+            elif line.split()[0] == IF:
                 line = line.split(IF)[1].strip()
             
                 # Handle Equality Form: ".if string == string"
@@ -590,6 +605,14 @@
                 elif line.count(NOTEQUIV):
                     pass
 
+            #####
+            # Line Started With IF, But Was Not In Any Knwon IF Form
+            #####
+
+            else:
+                ErrorMsg(eBADEXPR % (cfgfile, linenum, eIFBAD, orig))
+                    
+
         #####
         # Handle New Variable Declaration/Assignment
         #####