diff --git a/Modules/HeaderDoc/BlockParse.pm b/Modules/HeaderDoc/BlockParse.pm
index 26ad49f..e9601ca 100644
--- a/Modules/HeaderDoc/BlockParse.pm
+++ b/Modules/HeaderDoc/BlockParse.pm
@@ -814,6 +814,8 @@ sub blockParse
     my $asDebug                 = 0;
     my $reMarkDebug             = 0;
 
+    if ($asDebug && (!$HeaderDoc::AppleScriptDebug)) { $HeaderDoc::AppleScriptDebug = 1; }
+
     $cppDebug = $cppDebugDefault ? $cppDebugDefault : $HeaderDoc::fileDebug;
 
     # State variables (part 1 of 3)
@@ -1700,6 +1702,7 @@ if ($localDebug || $cppDebug) {foreach my $partlist (@parts) {print STDERR "POST
 			next;
 	    }
 	    print STDERR "PART IS \"$part\"\n" if ($localDebug || $parserStackDebug || $parseDebug || $liteDebug || $spaceDebug || $tokenDebug);
+	    print STDERR "SPS: ".scalar(@parserStack)." BSC: ".(scalar(@braceStack))." IBSC: ".$parserState->{initbsCount}."\n" if ($parserStackDebug);
 	    print STDERR "QUOTED: ".$parserState->isQuoted($lang, $sublang)."\n" if ($localDebug || $parserStackDebug || $parseDebug || $liteDebug || $spaceDebug);
 	    print STDERR "CURLINE IS \"$curline\"\n" if ($localDebug || $hangDebug || $liteDebug);
 	    # print STDERR "RETURNTYPE IS \"$parserState->{returntype}\"\n" if ($localDebug || $hangDebug || $liteDebug);
@@ -2469,7 +2472,7 @@ if ($localDebug || $cppDebug) {foreach my $partlist (@parts) {print STDERR "POST
 		 !($parserState->{inString} || $parserState->{inComment} || $parserState->{inInlineComment} ||
 		   $parserState->{inChar}) &&
 		 !$argparse && $labelregexp && ($part =~ /$labelregexp/) && ($parserState->{startOfDec} != 1)) && do {
-			print STDERR "APPLESCRIPT OF/IN: CASE AS_00C\n" if ($liteDebug);
+			print STDERR "APPLESCRIPT LABEL: CASE AS_00C\n" if ($liteDebug);
 			print STDERR "IN APPLESCRIPT LABEL: SET TO $part SOD=".$parserState->{startOfDec}."\n" if ($asDebug);
 			$parserState->{inLabel} = 1;
 			$parserState->{ASlabel} = $part;
@@ -2480,7 +2483,7 @@ if ($localDebug || $cppDebug) {foreach my $partlist (@parts) {print STDERR "POST
 		 !($parserState->{inString} || $parserState->{inComment} || $parserState->{inInlineComment} ||
 		   $parserState->{inChar}) &&
 		 $labelregexp && $parserState->{inLabel} && ($part =~ /\w/)) && do {
-			print STDERR "APPLESCRIPT OF/IN: CASE AS_00D\n" if ($liteDebug);
+			print STDERR "APPLESCRIPT LABEL: CASE AS_00D\n" if ($liteDebug);
 			print STDERR "IN APPLESCRIPT LABEL: ADDING $part\n" if ($asDebug);
 			$parserState->{ASlabel} .= " ".$part;
 			$parserState->{inLabel} = 0;
@@ -2491,7 +2494,7 @@ if ($localDebug || $cppDebug) {foreach my $partlist (@parts) {print STDERR "POST
 		 !($parserState->{inString} || $parserState->{inComment} || $parserState->{inInlineComment} ||
 		   $parserState->{inChar}) &&
 		 ($part eq "given")) && do {
-			print STDERR "APPLESCRIPT OF/IN: CASE AS_00E\n" if ($liteDebug);
+			print STDERR "APPLESCRIPT GIVEN: CASE AS_00E\n" if ($liteDebug);
 			print STDERR "IN APPLESCRIPT GIVEN ($part)\n" if ($asDebug);
 			$parserState->{inGiven} = 1;
 			$parserState->{inLabel} = 0;
@@ -2502,7 +2505,7 @@ if ($localDebug || $cppDebug) {foreach my $partlist (@parts) {print STDERR "POST
 		 !($parserState->{inString} || $parserState->{inComment} || $parserState->{inInlineComment} ||
 		   $parserState->{inChar}) &&
 		 ($part !~ /[\r\n]/)) && do {
-			print STDERR "APPLESCRIPT OF/IN: CASE AS_00F\n" if ($liteDebug);
+			print STDERR "APPLESCRIPT GIVEN: CASE AS_00F\n" if ($liteDebug);
 			print STDERR "IN APPLESCRIPT GIVEN\n" if ($asDebug);
 			if ($part eq ",") {
 				print STDERR "IN APPLESCRIPT GIVEN COMMA\n" if ($asDebug);
diff --git a/Modules/HeaderDoc/ParserState.pm b/Modules/HeaderDoc/ParserState.pm
index e09f9ce..b2fde35 100644
--- a/Modules/HeaderDoc/ParserState.pm
+++ b/Modules/HeaderDoc/ParserState.pm
@@ -490,6 +490,9 @@
 #             Set to the actual <code>of</code> or <code>in</code> token
 #             encountered when parsing AppleScript.  The word token after it is
 #             appended to this variable (delimited by a space).
+#         @var ASINELSE
+#             Set to 1 at an "else" statement.  If the next word token is "if",
+#             we don't treat it as opening a new brace.
 #         @var ASLBRACEPRECURSOR
 #             In an <code>if</code> or <code>tell</code> statement, stores
 #             the <code>if</code> or <code>tell</code> token.  Used to determine
@@ -1228,7 +1231,7 @@ use Carp qw(cluck);
 #         In the git repository, contains the number of seconds since
 #         January 1, 1970.
 #  */
-$HeaderDoc::ParserState::VERSION = '$Revision: 1368570551 $';
+$HeaderDoc::ParserState::VERSION = '$Revision: 1392792170 $';
 ################ General Constants ###################################
 my $debugging = 0;
 
@@ -1897,6 +1900,7 @@ sub isLeftBrace
 	my %parseTokens = ();
 
 	my $lbrace;
+	my $lbracepreventerre;
 	my $lbraceunconditionalre;
 	my $lbraceconditionalre;
 	my $lbraceprecursorre;
@@ -1918,6 +1922,7 @@ sub isLeftBrace
 		$curBraceCount = shift;
 		$lbraceprecursor = "";
 		$lbraceprecursorre = "";
+		$lbracepreventerre = "";
 	} else {
 		# New-style calling: use the value as a reference.
 		%parseTokens = %{$parseTokensRef};
@@ -1925,6 +1930,7 @@ sub isLeftBrace
 		$lbrace = $parseTokens{lbrace};
 		$lbraceunconditionalre = $parseTokens{lbraceunconditionalre};
 		$lbraceconditionalre = $parseTokens{lbraceconditionalre};
+		$lbracepreventerre = $parseTokens{lbracepreventerre};
 		$lbraceprecursorre = $parseTokens{lbraceprecursorre};
 		$classisbrace = $parseTokens{classisbrace};
 		$functionisbrace = $parseTokens{functionisbrace};
@@ -1945,9 +1951,26 @@ sub isLeftBrace
 		return 1;
 	}
 
-	if ($lbraceunconditionalre && ($part =~ /$lbraceunconditionalre/)) { return 1; }
+	print STDERR "INRBR: ".$self->{inrbraceargument}."\n" if ($localDebug || $HeaderDoc::AppleScriptDebug);
 
-	if ($lang eq "applescript" && !($self->{inString} || $self->{inComment} || $self->{inInlineComment})) {
+	if ($lbraceunconditionalre && ($part =~ /$lbraceunconditionalre/)) {
+		print STDERR "UNCONDITIONALRE MATCH\n" if ($localDebug || $HeaderDoc::AppleScriptDebug);
+		return 1;
+	}
+
+	if ($lbracepreventerre && ($part =~ /$lbracepreventerre/)) {
+		print STDERR "ASINELSE -> 1\n" if ($localDebug || $HeaderDoc::AppleScriptDebug);
+		$self->{ASINELSE} = 1;
+	} elsif ($self->{ASINELSE} && $part =~ /\w/) {
+		print STDERR "ASINELSE -> 0\n" if ($localDebug || $HeaderDoc::AppleScriptDebug);
+		$self->{ASINELSE} = 0;
+		if ($part eq "if") {
+			print STDERR "IGNORING IF\n" if ($localDebug || $HeaderDoc::AppleScriptDebug);
+			return 0;
+		}
+	}
+
+	if ($lang eq "applescript" && !($self->{inString} || $self->{inComment} || $self->{inInlineComment} || $self->{inLabel} || $self->{inrbraceargument})) {
 		print STDERR "ASPART: \"$part\" PC: ".$self->{ASLBRACEPRECURSOR}." PCTAG: ".$self->{ASLBRACEPRECURSORTAG}."\n" if ($localDebug || $HeaderDoc::AppleScriptDebug);
 
 		# After an if/then or a tell/to, if we see a non-space, non-comment token,
@@ -1960,7 +1983,10 @@ sub isLeftBrace
 			$self->{ASLBRACEPRECURSORTAG} = "";
 		}
 
-		# If we see the "if" or "tell" token, store it away.
+		# If we see the "if" or "tell" token, store it away, but be prepared to reverse
+		# that decision later, if it's right after a newline and turns into a conditional
+		# regex match.
+		my $oldprecursor = $self->{ASLBRACEPRECURSOR};
 		if ($lbraceprecursor && $part =~ /$lbraceprecursor/) {
 			$self->{ASLBRACEPRECURSOR} = $part;
 			print STDERR "Set ASLBRACEPRECURSOR to \"$part\"\n" if ($localDebug || $HeaderDoc::AppleScriptDebug);
@@ -1978,9 +2004,14 @@ sub isLeftBrace
 				$self->{ASLBRACEPRECURSORTAG} = $part;
 			}
 			print STDERR "Nope.\n" if ($localDebug || $HeaderDoc::AppleScriptDebug);
+			return 0;
 		} elsif ($self->{afterNL} && $lbraceconditionalre && $part =~ /$lbraceconditionalre/) {
+			print STDERR "CONDITIONALRE MATCH\n" if ($localDebug || $HeaderDoc::AppleScriptDebug);
+			$self->{ASLBRACEPRECURSOR} = $oldprecursor;
 			return 1;
 		}
+	} elsif ($lang eq "applescript") {
+		return 0;
 	} else {
 		if ($lbraceconditionalre && (!$self->{followingrubyrbrace}) && ($part =~ /$lbraceconditionalre/)) { return 1; }
 	}
diff --git a/Modules/HeaderDoc/Utilities.pm b/Modules/HeaderDoc/Utilities.pm
index 00e5db5..9229339 100644
--- a/Modules/HeaderDoc/Utilities.pm
+++ b/Modules/HeaderDoc/Utilities.pm
@@ -1672,9 +1672,12 @@ sub parseTokens
 	# These always start a block ending in "end"
 	# $parseTokens{lbraceunconditionalre} = "^(repeat|try)\$";
 
-	# These might, if they aren't followed by the corresponing simple token.
+	# These might, if they aren't followed by the corresponding simple token.
 	$parseTokens{lbraceprecursor} = "^(if|tell)\$";
 	$parseTokens{lbraceprecursorre} = "^(then|to)\$";
+	# If this is followed by an "if", ignore the "if".
+	$parseTokens{lbracepreventerre} = "^(else)\$";
+	# These do if they're after a newline.
 	$parseTokens{lbraceconditionalre} = "^(considering|ignoring|repeat|tell|try|using|with)\$";
 
 	# $parseTokens{rbrace} = "end";
diff --git a/Modules/HeaderDoc/BlockParse.pm b/Modules/HeaderDoc/BlockParse.pm
index e9601ca..c7300f6 100644
--- a/Modules/HeaderDoc/BlockParse.pm
+++ b/Modules/HeaderDoc/BlockParse.pm
@@ -3,7 +3,7 @@
 # Module name: BlockParse
 # Synopsis: Block parser code
 #
-# Last Updated: $Date: 2014/02/18 22:42:50 $
+# Last Updated: $Date: 2014/02/21 09:52:56 $
 # 
 # Copyright (c) 1999-2004 Apple Computer, Inc.  All rights reserved.
 #
@@ -122,7 +122,7 @@ use File::Basename qw(basename);
 #         In the git repository, contains the number of seconds since
 #         January 1, 1970.
 #  */
-$HeaderDoc::BlockParse::VERSION = '$Revision: 1392792170 $';
+$HeaderDoc::BlockParse::VERSION = '$Revision: 1393005176 $';
 
 ################ Portability ###################################
 my $isMacOS;
@@ -1642,6 +1642,9 @@ if ($localDebug || $cppDebug) {foreach my $partlist (@parts) {print STDERR "POST
 	    $treeSkip = 0;
 	    my $reMark = "";
 
+	    print "PARSER STATE COUNT: ".scalar(@parserStack)."\n" if ($parserStackDebug);
+	    $parserState->print() if ($parserStackDebug);
+
 	    print STDERR "INMACROLINE: ".$parserState->{inMacroLine}."\n" if ($localDebug || $parseDebug || $parmDebug);
 	    if ($part) { $leavingRegexp = 0; } # Reset to 0 at the top of the loop.
 
@@ -5966,8 +5969,18 @@ if (0) {
 			$parserState->{lastTreeNode} = $treeCur;
 			if ($lang eq "applescript") {
 				# AppleScript needs a little help because functions can contain other things.
-				$parserState->{lastDisplayNode} = $treeCur;
-				$treeTop->{lastDisplayNode} = $treeCur;
+				if (!$parserState->{lastDisplayNode}) {
+					$parserState->{lastDisplayNode} = $treeCur;
+				}
+				if (!$treeTop->{lastDisplayNode}) {
+					$treeTop->{lastDisplayNode} = $treeCur;
+				}
+				if (!$parserState->{lastDisplayNode}) {
+					$parserState->{lastDisplayNode} = $treeCur;
+				}
+				if (!$treeTop->{lastDisplayNode}) {
+					$treeTop->{lastDisplayNode} = $treeCur;
+				}
 
 				# print STDERR "CUR: $treeCur\n";
 				# print STDERR "FOR PS: $parserState\n";
diff --git a/testsuite/parser_tests/AppleScript_class_1.test b/testsuite/parser_tests/AppleScript_class_1.test
index 78ca9ee..5e80d28 100644
Binary files a/testsuite/parser_tests/AppleScript_class_1.test and b/testsuite/parser_tests/AppleScript_class_1.test differ
diff --git a/testsuite/parser_tests/AppleScript_class_2.test b/testsuite/parser_tests/AppleScript_class_2.test
index 2731d45..3b2a0c2 100644
Binary files a/testsuite/parser_tests/AppleScript_class_2.test and b/testsuite/parser_tests/AppleScript_class_2.test differ
diff --git a/testsuite/parser_tests/AppleScript_tell_1.test b/testsuite/parser_tests/AppleScript_tell_1.test
index cdf41a8..e978690 100644
Binary files a/testsuite/parser_tests/AppleScript_tell_1.test and b/testsuite/parser_tests/AppleScript_tell_1.test differ
