diff --git a/alib2/makefile b/alib2/makefile
index 0af199edbeb23f14081b1666434b1e1dbf6a88f9..d61428fbc45cd3f30df5b4a116617860aa95ca72 100644
--- a/alib2/makefile
+++ b/alib2/makefile
@@ -24,7 +24,7 @@ obj/makefile: makefile
 	echo "SRCDIR:=" >> $@
 	echo "DEPTH:=" >> $@
 	echo "" >> $@
-	echo "CXXFLAGS:= -std=c++11 -Og -g -c -Wall -pedantic -Wextra -fPIC -I/usr/include/libxml2/" >> $@
+	echo "CXXFLAGS:= -std=c++11 -O0 -g -c -Wall -pedantic -Wextra -fPIC -I/usr/include/libxml2/" >> $@
 	echo "" >> $@
 	echo "SOURCES:= \$$(shell find ../\$$(DEPTH)src/\$$(SRCDIR) -maxdepth 1 -type f -name \"*.cpp\")" >> $@
 	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)obj/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
@@ -79,7 +79,7 @@ test-obj/makefile: makefile
 	echo "SRCDIR:=" >> $@
 	echo "DEPTH:=" >> $@
 	echo "" >> $@
-	echo "CXXFLAGS:= -std=c++11 -Og -g -c -Wall -pedantic -Wextra -I../\$$(DEPTH)src/ -I/usr/include/libxml2/" >> $@
+	echo "CXXFLAGS:= -std=c++11 -O0 -g -c -Wall -pedantic -Wextra -I../\$$(DEPTH)src/ -I/usr/include/libxml2/" >> $@
 	echo "" >> $@
 	echo "SOURCES:= \$$(shell find ../\$$(DEPTH)test-src/\$$(SRCDIR) -maxdepth 1 -type f -name \"*.cpp\")" >> $@
 	echo "DEPENDENCIES:= \$$(patsubst ../\$$(DEPTH)test-src/\$$(SRCDIR)%.cpp, ../\$$(DEPTH)test-obj/\$$(SRCDIR)%.d, \$$(SOURCES))" >> $@
diff --git a/alib2/src/grammar/Unrestricted/UnrestrictedGrammar.cpp b/alib2/src/grammar/Unrestricted/UnrestrictedGrammar.cpp
index d621171b71aabfa7220e41036f47bae0f16201f9..ed842072fe49c3328bfeab7a2885ae90a33ee76a 100644
--- a/alib2/src/grammar/Unrestricted/UnrestrictedGrammar.cpp
+++ b/alib2/src/grammar/Unrestricted/UnrestrictedGrammar.cpp
@@ -73,13 +73,13 @@ bool UnrestrictedGrammar::addRule(const std::vector<alphabet::Symbol>& leftHandS
 	for(lContext = 0; lContext < lSize - 1 && leftHandSide[lContext] == rightHandSide[lContext]; lContext++);
 	for(rContext = 0; rContext < lSize - 1 && leftHandSide[lSize - rContext] == rightHandSide[rSize - rContext]; rContext++);
 
-	if(lContext + rContext + 1 < lSize)
+	if(lContext + rContext + 1 < lSize) {
 		throw GrammarException("Rule must rewrite only one symbol");
-
-	if(lContext + rContext + 1 == lSize && !nonterminalAlphabet.count(leftHandSide[lContext]))
-		throw GrammarException("Rule must rewrite nonterminal symbol");
-
-	if(/* lContext + rContext + 1 > lSize */ std::all_of(leftHandSide.begin(), leftHandSide.end(), [&](const alphabet::Symbol symbol) {return !nonterminalAlphabet.count(symbol);}))
+	} else
+	if(lContext + rContext + 1 == lSize) {
+		if(!nonterminalAlphabet.count(leftHandSide[lContext])) throw GrammarException("Rule must rewrite nonterminal symbol");
+	} else
+	if(/* lContext + rContext + 1 > lSize */ std::all_of(leftHandSide.end() - rContext + 1, leftHandSide.begin() + lContext - 1, [&](const alphabet::Symbol symbol) {return !nonterminalAlphabet.count(symbol);}))
 		throw GrammarException("Rule must rewrite nonterminal symbol");