diff --git a/CompilerGeneration.jrag b/CompilerGeneration.jrag
index c1fa8bbdf373af253b30645e496d44c4ea4f4658..6733e0c535032508fd6c09934a0b99bc81a8cf4d 100644
--- a/CompilerGeneration.jrag
+++ b/CompilerGeneration.jrag
@@ -19,7 +19,7 @@ aspect AbsGrammarGeneration {
 		pStream.print(getId());
 		pStream.print(" : "+getSuperClass().getId());	
 		pStream.print(" ::=");
-		Restrictions restrs = getRestrictions();
+		Restrictions restrs = getOwnRestrictions();
 		for (int i=0; i<restrs.getNumOwlRestriction(); i++) {
 			pStream.print(" ");
 			restrs.getOwlRestriction(i).genAbsGrammar(pStream);
@@ -138,13 +138,25 @@ aspect JavaCCGen {
 		pStream.println("void "+getId()+"() : {}");
 		pStream.println("{");
 		if (getId().equals("Device")) {
-			pStream.print("\"<\" <DEVICE> \">\"");
-			pStream.print("(Property())* (Skill())* MainFunction() #");
-			pStream.println("Device("+getNumRestriction()+")");
+			pStream.print("\"<\" ( <DEVICE> \">\"");
+			Restrictions restr = getRestrictions();
+			for (int i=0; i< getNumRestriction(); i++) {
+				OwlRestriction res = restr.getOwlRestriction(i);
+				pStream.print("("+res.getRestrictionClassId()+")"+
+							  (res.allValuesFrom()?"*":"")+" ");
+			}
+			pStream.println(" #Device("+getNumRestriction()+")");
+			// List all subclasses
+			pStream.println(")");
 		} else {
 			pStream.print(" <"+getId().toUpperCase()+"> \">\"");
-			pStream.print("(Property())* (Skill())* MainFunction() #");
-			pStream.println(getId()+"("+getNumRestriction()+")"); 
+			Restrictions restr = getRestrictions();
+			for (int i=0; i< getNumRestriction(); i++) {
+				OwlRestriction res = restr.getOwlRestriction(i);
+				pStream.print("("+res.getRestrictionClassId()+")"+
+							  (res.allValuesFrom()?"*":"")+" ");
+			}
+			pStream.println(" #"+getId()+"("+getNumRestriction()+")");
 		}
 		pStream.println("}");
 	}
diff --git a/Types.jrag b/Types.jrag
index 1f72e9b3a28c7a889e2e4a41229aaa0db74768ea..74579da7252bc92a53ec4f4b971cce17bdc3c5e5 100644
--- a/Types.jrag
+++ b/Types.jrag
@@ -56,12 +56,12 @@ aspect Types {
 aspect Restrictions {
   
 	Restrictions OwlClassDecl.restrictions;
+	Restrictions OwlClassDecl.ownRestrictions;
   
 	syn lazy Restrictions OwlClassDecl.getRestrictions() {
 		if (restrictions == null) {
 			List l = new List();
 			collectRestrictions(l);
-			getSuperClass().decl().collectRestrictions(l);
 			restrictions = new Restrictions(l);
 		}
 		return restrictions;
@@ -72,12 +72,41 @@ aspect Restrictions {
 			getChild(i).collectRestrictions(l);
 		}
 	}
+
+	void OwlClassDecl.collectRestrictions(List l) {
+		if (!getSuperClass().getId().equals("Thing")) {
+			getSuperClass().decl().collectRestrictions(l);
+		}
+		super.collectRestrictions(l);
+	}
   
 	void OwlRestriction.collectRestrictions(List l) {
 		l.add(this);
 	}
 	
 	syn int OwlClassDecl.getNumRestriction() = getRestrictions().getNumOwlRestriction();
+
+	syn lazy Restrictions OwlClassDecl.getOwnRestrictions() {
+		if (ownRestrictions == null) {
+			List l = new List();
+			collectOwnRestrictions(l);
+			ownRestrictions = new Restrictions(l);
+		}
+		return ownRestrictions;
+	}
+
+	void ASTNode.collectOwnRestrictions(List l) {
+		for (int i=0; i<getNumChild(); i++) {
+			getChild(i).collectOwnRestrictions(l);
+		}
+	}
+
+	void OwlRestriction.collectOwnRestrictions(List l) {
+		l.add(this);
+	}
+	
+	syn int OwlClassDecl.getNumOwnRestriction() = 
+		getOwnRestrictions().getNumOwlRestriction();
 }
 
 aspect Properties {
diff --git a/owl.ast b/owl.ast
index 19b4e6754cbdbad4f631f67de7d16304553dfde7..151d9e4a4236250bd630b79f78359c6804fb45c8 100644
--- a/owl.ast
+++ b/owl.ast
@@ -64,9 +64,9 @@ Value ::= <STRING_LITERAL>;
 
 
 // Types used by rewrite rules
-abstract OClass : ComplexElement;
-OwlClassDecl : OClass ::= <Id:String> ;
-OwlClassUse : OClass ::= <Id:String> ;
+abstract OClass : ComplexElement ::= <Id:String>;
+OwlClassDecl : OClass;
+OwlClassUse : OClass;
 
 abstract OwlValuesFrom: ComplexElement;