diff --git a/src/fr/inrialpes/exmo/align/gen/AlteratorFactory.java b/src/fr/inrialpes/exmo/align/gen/AlteratorFactory.java
index 1ee58eae25f7486c5d86a087ae229e69939131ba..d80cd615fa16355a456df434b54a4f5fea110828 100644
--- a/src/fr/inrialpes/exmo/align/gen/AlteratorFactory.java
+++ b/src/fr/inrialpes/exmo/align/gen/AlteratorFactory.java
@@ -35,6 +35,7 @@ public class AlteratorFactory {
     private static Map<String,String> alterators = null;
 
     public static Alterator newInstance( String id, Alterator om ) {
+	//System.err.println( ">>>>>>>> "+id );
 	if ( alterators == null ) init();
 	String classname = alterators.get( id );
 	Alterator alt = null;
diff --git a/src/fr/inrialpes/exmo/align/gen/ClassHierarchy.java b/src/fr/inrialpes/exmo/align/gen/ClassHierarchy.java
index 4435024b0f069436e3a0c702995427854cb36d8c..8d91c1bd299d484ff5183b49e1b970c5137a95c8 100644
--- a/src/fr/inrialpes/exmo/align/gen/ClassHierarchy.java
+++ b/src/fr/inrialpes/exmo/align/gen/ClassHierarchy.java
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- * Copyright (C) 2011, INRIA
+ * Copyright (C) 2011-2012, INRIA
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -32,87 +32,71 @@ import com.hp.hpl.jena.ontology.Restriction;
 import com.hp.hpl.jena.rdf.model.Resource;
 import com.hp.hpl.jena.shared.PrefixMapping;
 import com.hp.hpl.jena.vocabulary.OWL;
+
 //Java
-import java.util.*;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Properties;
+import java.util.ArrayList;
+import java.util.Random;
+import java.util.Iterator;
 
 public class ClassHierarchy {
     private URITree root;							//the root of the tree
     private Map m_anonIDs = new HashMap();
     private int m_anonCount = 0;
-    private int maxDepth;							//the max depth of class hierarchy
 
     public ClassHierarchy() {}
 
     //return the root of the hierarchy
-    public URITree getRootClassHierarchy () {
-        return this.root;
+    public URITree getRootClassHierarchy() {
+        return root;
     }
 
     //return the max level of the hierarchy
     public int getMaxLevel() {
-        this.maxDepth = this.root.getMaxDepth();
-        return this.maxDepth;
-    }
-
-    //print class hierarchy
-    public void printClassHierarchy() {
-        System.out.println( "[--------------------]" );
-        System.out.println( "The class hierarchy" );
-        root.printURITree(this.root);						//we print the tree
-        System.out.println( "The class hierachy" );
-        System.out.println( "[---------------------]" );
+        return root.getMaxDepth();
     }
 
-    public void addClass (String childURI, String parentURI) {
-        URITree node = null;
-        this.getRootClassHierarchy().add(this.root, parentURI, childURI);       //we add the new childURI to the hierarchy
+    public void addClass( String childURI, String parentURI ) {
+        root.add( root, parentURI, childURI );       //we add the new childURI to the hierarchy
     }
 
     //updates the class hierarchy
-    public void updateClassHierarchy (Properties params) {
-        this.root.renameTree(this.root, params);
+    public void updateClassHierarchy( Properties alignment ) {
+        root.renameTree( alignment );
     }
 
     //returns the list of classes from level level
-    public List<OntClass> getClassesFromLevel (OntModel model, int level) {
-        List <URITree> nodes = this.getNodesFromLevel(level);			//get all the nodes from the specific level
+    public List<OntClass> getClassesFromLevel( OntModel model, int level ) {
         ArrayList<OntClass> classes = new ArrayList<OntClass>();
-        for ( int i=0; i<nodes.size(); i++ )
-            classes.add( model.getOntClass( nodes.get(i).getURI() ) );          //builds the list of classes
+	for ( URITree node : getNodesFromLevel(level) ) {
+            classes.add( model.getOntClass( node.getURI() ) );          //builds the list of classes
+	}
         return classes;
     }
 
     //get the nodes from a specific level
-    public List<URITree> getNodesFromLevel (int level) {
-        return this.getRootClassHierarchy().getNodesFromLevel(this.root, level);
-    }
-
-    //remove URI from the class hierarchy
-    public void removeUri(URITree root, String uri) {
-        root.removeFromURITree(root, uri);					//remove URI uri from the class hierarchy
+    public List<URITree> getNodesFromLevel( int level ) {
+        return root.getNodesFromLevel( root, level);
     }
 
     //remove the URI of the class from the hierarchy
     //returns the parent of the class if it exists or 0 other way -> not owl:Thing
-    public OntClass removeClass (OntModel model, OntClass cls) {
-        URITree node = this.root.searchURITree( this.root, cls.getURI() );	//search for the class URI in the class hierarchy
-        URITree parentNode = null;
-
+    public OntClass removeClass ( OntModel model, OntClass cls ) {
+        URITree node = root.searchURITree( cls.getURI() );	//search for the class URI in the class hierarchy
         int depth = node.getDepth();						//get the depth of the node
-        parentNode = node.getParent();						//get the parent of the node
+        URITree parentNode = node.getParent();						//get the parent of the node
         for ( URITree child : node.getChildrenList() ) {                        //change the parent of the subclasses of the node
             child.setDepth( depth );						//change the depth of the child
             child.setParent( parentNode );					//set the parent of the child
             parentNode.getChildrenList().add( child );                          //add the child to the parent children
         }
-
         parentNode.getChildrenList().remove( node );                            //remove the node from children list
         if ( depth == 1 ) {							//the parent is owl:Thing
-            OntClass thing = model.createClass( OWL.Thing.getURI() );           //Thing class
-            return thing;
-        }
-        else
-            return model.getOntClass( node.getParent().getURI() );              //return the parent class
+            return model.createClass( OWL.Thing.getURI() );           //Thing class
+        } else return model.getOntClass( node.getParent().getURI() );              //return the parent class
     }
 
     //return a random class from the level - level
@@ -123,57 +107,58 @@ public class ClassHierarchy {
         return model.getOntClass( childrenNodes.get(index).getURI() );          //returns the class from the position that we have selected -> the random number
     }
 
-
     //modifies the class hierarchy after we have flattened it
-    public boolean flattenClassHierarchy ( OntModel model, int level, ArrayList<OntClass> childClasses,
+    public void flattenClassHierarchy( OntModel model, int level, ArrayList<OntClass> childClasses,
                                         ArrayList<OntClass> parentClasses, ArrayList<OntClass> superLevelClasses) {
         List<URITree> childrenNodes = getNodesFromLevel( level );
-
-        URITree parentNode = null;
-        URITree superNode = null;
-        boolean active = true;
         for ( URITree childNode : childrenNodes ) {				//for each child class
-            parentNode = childNode.getParent();					//get the parent node
-
-            superNode = parentNode.getParent();					//get the parents of the parent node
-
+            URITree parentNode = childNode.getParent();					//get the parent node
+            URITree superNode = parentNode.getParent();					//get the parents of the parent node
             childClasses.add( model.getOntClass( childNode.getURI() ) );        //build the list of children classes
             parentClasses.add( model.getOntClass( parentNode.getURI() ) );	//build the list of parent classes
 
             if ( !superNode.getURI().equals( "Thing" ) ) {			//if the parent of the child class is not owl:Thing (1st level class)
                 superLevelClasses.add( model.getOntClass( superNode.getURI() ) );//build the list of the parents of the parent classes
-                active = true;							//set the flag -> we don't have a 1st level class
-            }
-            else {
-                active = false;							//set the flag -> we have a 1st level class
-            }
-        }
-
-        flattenHierarchy( childrenNodes );					//modify the links among the nodes from the class hierarchy
-        this.getRootClassHierarchy().changeDepth ( this.getRootClassHierarchy(), level );//change the depth
-        return active;
-    }
-
-    //modify the links between the nodes from the class hierarchy
-    public void flattenHierarchy (List<URITree> childrenNodes ) {
-        URITree parentNode;
-
-        for ( URITree childNode : childrenNodes ) {
-            parentNode = childNode.getParent();					//get the parent of the node
+            } else {
+                superLevelClasses.add( null ); //set an explicit null
+	    }
+	    /*
+	    if ( childClasses.get(childClasses.size()-1) != null ) {
+		System.err.print( childClasses.get(childClasses.size()-1).getURI() );
+	    } else {
+		System.err.print( "**NULL**" );
+	    }
+	    System.err.print( " < ");
+	    if ( parentClasses.get(childClasses.size()-1) != null ) {
+		System.err.print( parentClasses.get(childClasses.size()-1).getURI() );
+	    } else {
+		System.err.print( "**NULL**" );
+	    }
+	    System.err.print( " < ");
+	    if ( superLevelClasses.get(childClasses.size()-1) != null ) {
+		System.err.print( superLevelClasses.get(childClasses.size()-1).getURI() );
+	    } else {
+		System.err.print( "**NULL**" );
+	    }
+	    System.err.println();
+	    */
             childNode.setParent( parentNode.getParent() );			//change the parent of my superclass to the [parent of the "parent node"]
-
+	    // JE : likely wrong in multiple inheritance
             childNode.setDepth( parentNode.getDepth() );			//change it's depth
-
             parentNode.getChildrenList().remove( childNode );			//remove it from the children list of parentNode
-            parentNode.getParent().getChildrenList().add( childNode );		//add it to the children list of superClass
-        }
+            superNode.getChildrenList().add( childNode );		//add it to the children list of superClass
+	    // JE: removed...
+            superNode.getChildrenList().remove( parentNode );			//remove it from the children list of parentNode
+        } 
+        //flattenHierarchy( childrenNodes );					//modify the links among the nodes from the class hierarchy
+        root.changeDepth ( root, level ); //change the depth
     }
 
     //builds the class hierarchy
     @SuppressWarnings("unchecked")
     public void buildClassHierarchy(OntModel model) {
         Iterator i =  model.listHierarchyRootClasses();
-        this.root = new URITree( "Thing" );					//the root of the hierarchy is always owl:Thing
+        root = new URITree( "Thing" );					//the root of the hierarchy is always owl:Thing
 
         //get the list of root classes
         List<OntClass> ontologyClasses = model.listClasses().toList();
@@ -193,16 +178,15 @@ public class ClassHierarchy {
                 }
             }
         }
-        this.maxDepth = this.root.getMaxDepth();
     }
 
     @SuppressWarnings("unchecked")
-    public void getClass (OntClass cls, List occurs, int depth) {
+    public void getClass ( OntClass cls, List occurs, int depth ) {
         renderClassDescription( cls, depth );
 
         if ( cls.canAs( OntClass.class )  &&  !occurs.contains( cls ) ) {	// recurse to the next level down
-            for (Iterator i = cls.listSubClasses( true );  i.hasNext(); ) {
-                OntClass sub = (OntClass) i.next();
+            for ( Iterator it = cls.listSubClasses( true );  it.hasNext(); ) {
+                OntClass sub = (OntClass)it.next();
                 occurs.add( cls );						// we push this expression on the occurs list before we recurse
                 getClass( sub, occurs, depth + 1 );
                 occurs.remove( cls );
@@ -210,6 +194,17 @@ public class ClassHierarchy {
         }
     }
 
+    // **************************************************
+    // Rendering functions
+    //print class hierarchy
+    public void printClassHierarchy() {
+        System.out.println( "[--------------------]" );
+        System.out.println( "The class hierarchy" );
+        root.printURITree( root );						//we print the tree
+        System.out.println( "The class hierachy" );
+        System.out.println( "[---------------------]" );
+    }
+
     @SuppressWarnings("unchecked")
     public void renderClassDescription( OntClass c, int depth ) {
         if (c.isRestriction()) {
@@ -231,16 +226,15 @@ public class ClassHierarchy {
 
                         //it the superclass is .../#Thing
                         if ( parentURI.contains( "Thing" ) )
-                            this.getRootClassHierarchy().add(this.root, uri, "Thing");
+                            root.add( root, uri, "Thing");
                         else
-                            this.root.add(this.root, uri, parentURI);
+                            root.add( root, uri, parentURI);
                     }
                 }
 
                 if ( found == 0 ) 						//has no parent until now
-                    this.getRootClassHierarchy().add(this.root, uri, "Thing");
-            }
-            else {
+                    root.add( root, uri, "Thing");
+            } else {
                 renderAnonymous( c, "class" );					//an anonymous class
             }
         }
diff --git a/src/fr/inrialpes/exmo/align/gen/URITree.java b/src/fr/inrialpes/exmo/align/gen/URITree.java
index b0f69f6aac9257b4a4e190ec45b84d16c18403c9..6a52937f4655ef2766c74e29f5e12108ed46519e 100644
--- a/src/fr/inrialpes/exmo/align/gen/URITree.java
+++ b/src/fr/inrialpes/exmo/align/gen/URITree.java
@@ -1,7 +1,7 @@
 /*
- * $Id: URITree.java$
+ * $Id$
  *
- * Copyright (C) 2011, INRIA
+ * Copyright (C) 2011-2012, INRIA
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -29,6 +29,8 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
 
+import fr.inrialpes.exmo.align.gen.alt.BasicAlterator;
+
 public class URITree {
     private String URI;                 //the URI of the node
     private ArrayList<URITree> children;//the list of children
@@ -36,170 +38,135 @@ public class URITree {
     int depth;				//the depth of the node
     int maxDepth;			//the max depth of the node
 	
-    public URITree(String URI) {
+    public URITree( String URI ) {
         this.URI = URI;
-        this.children = new ArrayList<URITree>();
-        this.parent = null;
-	this.depth = 0;
-	this.maxDepth = 0;
+        children = new ArrayList<URITree>();
+        parent = null;
+	depth = 0;
+	maxDepth = 0;
     }
 
     //get the URI of the node
     public String getURI () {
-        return this.URI;
+        return URI;
     }
 	
     //set the URI of the node
-    public void setURI(String URI) {
+    public void setURI( String URI ) {
         this.URI = URI;
     }
 	
     //set the depth of the node
-    public void setDepth (int depth) {
+    public void setDepth( int depth ) {
         this.depth = depth;
     }
 	
     //get the depth of the node
     public int getDepth() {
-        return this.depth;
+        return depth;
     }
 	
     //return the max depth
     public int getMaxDepth() {
-        return this.maxDepth;
+        return maxDepth;
     }
 	
     //set the parent of the node
-    public void setParent ( URITree parent ) {
+    public void setParent( URITree parent ) {
         this.parent = parent;
     }
 	
     //get the parent of the node
     public URITree getParent () {
-        return this.parent;
+        return parent;
    }
 	
     //returns a child from a specific position
     public URITree getChildAt ( int index ) {
-        return this.children.get( index );
+        return children.get( index );
     }
 	
     //return the list of children nodes
     public ArrayList<URITree> getChildrenList() {
-        return this.children;
+        return children;
     }
 	
     //returns the size of the children
     public int getChildrenSize() {
-        return this.children.size();
+        return children.size();
     }
 
     //add the node with the childURI to the parent with the URI parentURI
-    public void add(URITree root, String childURI, String parentURI) {
+    public void add( URITree root, String childURI, String parentURI ) {
         //adds the node to the class hierarchy -> a class might have more than one 
         //superclass we have to add it to each superclass in part, not only to one
         _addChildToNode( root, parentURI, childURI );
     }
 
     //add a child
-    public void addChild (URITree root, URITree node, String URI) {
-        int index = 0;
-        URITree n = null;
-		
-	while ( index < node.getChildrenSize() ) {                              //if the child is already in the list
-            if ( node.getChildAt( index ).getURI().equals( URI ) )
-                return;
-            index++;
+    public void addChild( URITree root, URITree node, String URI ) {
+	// If already child, forget it
+	for ( URITree n : node.getChildrenList() ) {
+            if ( n.getURI().equals( URI ) ) return;
         }
-
-        index = 0;
-	while ( index < root.getChildrenSize() ) {                              //we search among root children to see if the node is already there
-            n = root.getChildrenList().get( index );
-            if ( n.getURI().equals( URI ) )	{                               //the node is already there
-                root.getChildrenList().remove( n );                             //we remove the node
-                break;
-            }
-            index++;
+	// If already existing, suppress it
+	URITree toRemove = null;
+	for ( URITree n : root.getChildrenList() ) {
+	    if ( n.getURI().equals( URI ) ) {
+		toRemove = n;
+		break;
+	    }
         }
+	root.getChildrenList().remove( toRemove );
+	// Now, go and create it
         addChildToNode( node, URI );
     }
 	
     //add child to a specific node
-    public void addChildToNode(URITree node, String URI) {
+    public void addChildToNode( URITree node, String URI ) {
         URITree child = new URITree( URI );                                     //creates a new node
-        child.setDepth( node.getDepth() + 1 );                                  //set the depth of the node
-		
-        if ( this.maxDepth < node.getDepth()+1  )                               //keeps track of the max depth of the hierarchy
-            this.maxDepth = node.getDepth() + 1;
-       
+        child.setDepth( node.getDepth()+1 );                                  //set the depth of the node
+        if ( maxDepth < node.getDepth()+1 )                               //keeps track of the max depth of the hierarchy
+            maxDepth = node.getDepth()+1;
         child.setParent( node );                                                //sets the parent of the node
         node.getChildrenList().add( child );                                    //adds the node to the parent children list
     }
 
     //renames the class from the tree after we have renamed the classes
-    @SuppressWarnings("unchecked")
-    public void renameTree(URITree root, Properties params) {
-        int index = 0;
-        URITree node = root;
-        URITree ans = null;
-        String uri;
-
-        //the uri changed
-        while ( index < root.getChildrenSize() ) {                              //we start to search recursively
-            uri = root.getChildAt( index ).getURI();
-            if ( params.containsKey( uri ) ) {
-                if ( !params.get( uri ).equals( uri ) )
-                    root.getChildAt( index ).setURI( (String)params.get( uri ) );
-            }
-            rename(root.getChildAt( index ), new ArrayList(),  0, params);
-            index++;
-        }
+    public void renameTree( Properties alignment ) {
+	rename( alignment, (String)alignment.get( "##" ) );
     }
 
     @SuppressWarnings("unchecked")
-    public void rename(URITree node, List occurs, int depth, Properties params) {
-        int index = 0;
-        URITree ans = null;
-        //verifies if the label of the URITree is the one with the label of the URITree we search for
-        String uri = node.getURI();
-        if ( params.containsKey( uri ) ) {
-            if ( !params.get( uri ).equals( uri ) ) {
-                node.setURI( (String)params.get( uri ) );
-            }
-        }
-
-        while( index < node.getChildrenSize()) {
-            URITree n = node.getChildAt( index );
-            occurs.add( node );
-            rename( n, occurs, depth+1, params );
-            occurs.remove( node );
-            index++;
-        }
+    public void rename( Properties alignment, String ns ) {
+	String key = BasicAlterator.getLocalName( getURI() );
+	String val = (String)alignment.get( key );
+	if ( val != null && !val.equals( key ) ) setURI( ns+val );
+	for ( URITree child : getChildrenList() ) {
+	    child.rename( alignment, ns );
+	}
     }
 
     //returns the URITree with the given URI
     @SuppressWarnings("unchecked")
     public void _addChildToNode(URITree root, String parentURI, String childURI) {
-        int index = 0;
-
         if ( root.getURI().equals( parentURI ) ) {				//if the root has the URI as the URI searched
             //addChildToNode(root, URI);
-            addChild (root, root, childURI);                                    //then add the child
+            addChild ( root, root, childURI );                                    //then add the child
             return;
-        }
-
-        while ( index < root.getChildrenSize() ) {                              //we start to search recursively
-            if ( root.getChildAt( index ).getURI().equals( parentURI ) ) {
-                //addChildToNode(root.getChildAt(index), URI);                  //we found the node with the given URI, then we add the child
-                addChild (root, root.getChildAt(index), childURI);
-            }
-            _addChild(root, root.getChildAt( index ), new ArrayList(),  0, parentURI, childURI);
-            index++;
-        }
+        } else {
+	    for( URITree node : root.getChildrenList() ) {                              //we start to search recursively
+		if ( node.getURI().equals( parentURI ) ) {
+		    //addChildToNode(root.getChildAt(index), URI);                  //we found the node with the given URI, then we add the child
+		    addChild( root, node, childURI );
+		}
+		_addChild( root, node, 0, parentURI, childURI );
+	    }
+	}
     }
 
     @SuppressWarnings("unchecked")
-    public void  _addChild(URITree root, URITree node, List occurs, int depth, String parentURI, String childURI) {
+    public void  _addChild(URITree root, URITree node, int depth, String parentURI, String childURI) {
         int index = 0;
         URITree ans = null;
         //verify if the label of the URITree is the one with the label of the URITree we search for
@@ -210,59 +177,27 @@ public class URITree {
 
         while( index < node.getChildrenSize()) {
             URITree n = node.getChildAt( index );
-            occurs.add( node );
-            _addChild( root, n, occurs, depth+1, parentURI, childURI );
-            occurs.remove( node );
+            _addChild( root, n, depth+1, parentURI, childURI );
             index++;
         }
     }
 
     //returns the URITree with the given URI
     @SuppressWarnings("unchecked")
-    public URITree searchURITree(URITree root, String URI) {
-        int index = 0;
-        URITree node = root;
-        URITree ans = null;
-		
-        if ( root.getURI().equals( URI ) )                                      //if the root has the URI as the URI searched
-            return root;
-		
-        while ( index < root.getChildrenSize() ) {                              //we start to search recursively
-            if ( root.getChildAt( index ).getURI().equals( URI ) )
-                return root.getChildAt( index );                                //we found the node with the given URI
-            ans = search(root.getChildAt( index ), new ArrayList(),  0, URI);
-            if ( ans != null )
-                return ans;
-            index++;
+    public URITree searchURITree( String URI ) {
+        if ( getURI().equals( URI ) ) return this;                         //if the root has the URI as the URI searched
+	for ( URITree node : getChildrenList() ) {                  //we start to search recursively
+            URITree ans = node.searchURITree( URI );
+            if ( ans != null ) return ans;
         }
-        return node;
-    }
-
-    @SuppressWarnings("unchecked")
-    public URITree search(URITree node, List occurs, int depth, String URI) {
-        int index = 0;
-        URITree ans = null;
-        //verify if the label of the URITree is the one with the label of the URITree we search for
-        if ( node.getURI().equals( URI ) ) {
-            ans = node;
-            return ans;                                                         //has found the parent
-        }
-
-        while( index < node.getChildrenSize()) {
-            URITree n = node.getChildAt( index );
-            occurs.add( node );
-            ans = search( n, occurs, depth+1, URI );
-            if ( ans != null )
-                return ans;
-            occurs.remove( node );
-            index++;
-        }
-        return null;                                                            //has not found the parent
+        return null;
     }
 
+    // JE: commented because never used
+    /*
     //remove a child from the tree
     @SuppressWarnings("unchecked")
-    public void removeFromURITree(URITree root, String URI) {
+    public void removeFromURITree( URITree root, String URI ) {
         int index = 0;
         int found = 0;
 
@@ -272,13 +207,13 @@ public class URITree {
                 //return;
             }
 			
-            remove(root.getChildAt( index ), new ArrayList(),  0, URI);
+            remove(root.getChildAt( index ), 0, URI);
             index++;
         }
     }
 	
     @SuppressWarnings("unchecked")
-    public void remove(URITree node, List occurs, int depth, String URI) {
+    public void remove( URITree node, int depth, String URI) {
         int index = 0;
         int found = 0;
 
@@ -298,14 +233,12 @@ public class URITree {
 		
         while( index < node.getChildrenSize()) {
             URITree n = node.getChildAt( index );
-            occurs.add( node );
-            remove( n, occurs, depth+1, URI );
-            occurs.remove( node );
+            remove( n, depth+1, URI );
             index++;
         }
 
     }
-
+    */
     //get all the node from a specific level
     @SuppressWarnings("unchecked")
     public List<URITree> getNodesFromLevel (URITree root, int level) {
@@ -314,40 +247,38 @@ public class URITree {
         if ( root.getDepth() == level )
             nodes.add( root );
         while ( index < root.getChildrenList().size() ) {
-            getNodes ( root.getChildAt(index), new ArrayList(), 0, nodes, level );//recursively print all the children URITrees
+            getNodes ( root.getChildAt(index), 0, nodes, level );//recursively print all the children URITrees
             index++;
         }
         return nodes;                                                           //return the list of nodes
     }
 
     @SuppressWarnings("unchecked")
-    public void getNodes (URITree node, List occurs, int depth, List<URITree> nodes, int level) {
+    public void getNodes (URITree node, int depth, List<URITree> nodes, int level) {
         int index = 0;
         if ( node.getDepth() == level )                                         //if it's on the level that we want, we add it to the hierarchy
             nodes.add( node );
 
         while( index < node.getChildrenList().size() ) {
             URITree n = node.getChildrenList().get(index);
-            occurs.add( node );
-            getNodes( n, occurs, depth+1, nodes, level );
-            occurs.remove( node );
+            getNodes( n, depth+1, nodes, level );
             index++;
         }
     }
 	
     //change the depth if the nodes lower the level to node.getDepth()-1
     @SuppressWarnings("unchecked")
-    public void changeDepth (URITree root, int level) {
+    public void changeDepth( URITree root, int level ) {
         int index = 0;
-        this.maxDepth = this.maxDepth-1;
+        maxDepth--;
         while ( index < root.getChildrenList().size() ) {
-            change ( root.getChildAt(index), new ArrayList(), 0, level );
+            change ( root.getChildAt(index), 0, level );
             index++;
         }
     }
 
     @SuppressWarnings("unchecked")
-    public void change (URITree node, List occurs, int depth, int level) {
+    public void change (URITree node, int depth, int level) {
         int index = 0;
 		
         if ( node.getDepth() > level ) 	{                                       //if it's on the level that we want, we add it to the hierarchy
@@ -357,9 +288,7 @@ public class URITree {
 		
         while( index < node.getChildrenList().size() ) {
             URITree n = node.getChildrenList().get(index);
-            occurs.add( node );
-            change( n, occurs, depth+1, level );
-            occurs.remove( node );
+            change( n, depth+1, level );
             index++;
         }
     }
@@ -368,26 +297,24 @@ public class URITree {
     @SuppressWarnings("unchecked")
     public void printURITree( URITree root ) {
         int index = 0;
-        //System.out.println( "[" + root.getURI() + "]" + "->" + root.getDepth() );
+        //System.err.println( "[" + root.getURI() + "]" + "->" + root.getDepth() );
 		
         while ( index < root.getChildrenList().size() ) {
             //recursively print all the children URITrees
-            print(root.getChildAt(index), new ArrayList(),  0);
+            print(root.getChildAt(index), 0);
             index++;
         }
     }
 
     @SuppressWarnings("unchecked")
-    public void print (URITree node, List occurs, int depth)  {
+    public void print (URITree node, int depth)  {
         int index = 0;
         indent( node.getDepth() );
-        System.out.println( "[" + node.getURI() + "]" + "->" + node.getDepth() );
+        //System.err.println( "[" + node.getURI() + "]" + "->" + node.getDepth() );
 		
         while( index < node.getChildrenList().size() ) {
             URITree n = node.getChildrenList().get( index );
-            occurs.add( node );
-            print( n, occurs, depth+1 );
-            occurs.remove( node );
+            print( n, depth+1 );
             index++;
         }
     }
diff --git a/src/fr/inrialpes/exmo/align/gen/alt/AddClassLevel.java b/src/fr/inrialpes/exmo/align/gen/alt/AddClassLevel.java
index 308a5d4082f3899872fa408a0df2bf689c7e7da7..e0075602fbcc4f3dc220fe02ad4659ca750af44a 100755
--- a/src/fr/inrialpes/exmo/align/gen/alt/AddClassLevel.java
+++ b/src/fr/inrialpes/exmo/align/gen/alt/AddClassLevel.java
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- * Copyright (C) 2011, INRIA
+ * Copyright (C) 2011-2012, INRIA
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -57,7 +57,7 @@ public class AddClassLevel extends BasicAlterator {
 
         buildClassHierarchy();                                                  //check if the class hierarchy is built
         if ( level == 1 ) {                                                     //the parent of the class is Thing, we add the class and then the rest of the classes
-           classURI = this.getRandomString();
+           classURI = getRandomString();
            parentClass = modifiedModel.createClass( modifiedOntologyNS + classURI );//create a new class to the model
            classHierarchy.addClass( modifiedOntologyNS + classURI, "Thing" );  //add the node in the hierarchy of classes
            childClasses.add(parentClass);
@@ -68,7 +68,7 @@ public class AddClassLevel extends BasicAlterator {
             int toAdd = Math.round( percentage*nbClasses );                       // 1 can be replaced by percentage
 
             for ( OntClass pClass : parentClasses ) {
-                classURI = this.getRandomString();
+                classURI = getRandomString();
                 childClass = addClass (pClass, classURI );
                 pClass = childClass;
                 childClasses.add( childClass );
@@ -76,9 +76,8 @@ public class AddClassLevel extends BasicAlterator {
         }
 
         for ( OntClass pClass : childClasses ) {
-            classURI = pClass.getLocalName();
+	    classURI = "IS_" + getLocalName( pClass.getURI() );
             for ( int i=level+1; i<level + nbClasses; i++ ) {
-                classURI = "IS_" + classURI;
                 childClass = addClass (pClass, classURI);
                 pClass = childClass;
             }	//this.classHierarchy.printClassHierarchy();
diff --git a/src/fr/inrialpes/exmo/align/gen/alt/BasicAlterator.java b/src/fr/inrialpes/exmo/align/gen/alt/BasicAlterator.java
index 4db3f5ffd228e837b13526e6254e5c989ac3b60e..4f137da8dea5d2b17e8e14f795613e2207b3e7d5 100644
--- a/src/fr/inrialpes/exmo/align/gen/alt/BasicAlterator.java
+++ b/src/fr/inrialpes/exmo/align/gen/alt/BasicAlterator.java
@@ -162,6 +162,32 @@ public abstract class BasicAlterator implements Alterator {
 
     public String getBase() { return initOntologyNS; }
 
+    // -------------------------
+    // Utility (URI) functions
+    // This is a roundabout for a Jena but which is not able to 
+    // correctly get the local name if it contains non alphabetical characters
+
+    public static String getLocalName( String uri ) {
+	if ( uri == null ) return null;
+	int index = uri.lastIndexOf("#");
+	if ( index == -1 ) {
+	    index = uri.lastIndexOf("/");
+	    return uri.substring( index+1 );
+	} else {
+	    return uri.substring( index+1 );
+	}
+    }
+
+    public static String getNameSpace( String uri ) {
+	int index = uri.lastIndexOf("#");
+	if ( index == -1 ) {
+	    index = uri.lastIndexOf("/");
+		return uri.substring( 0, index+1 );
+	} else {
+	    return uri.substring( 0, index+1 );
+	}
+    }
+
     // -------------------------
     // Utility (string) functions
 
@@ -219,11 +245,12 @@ public abstract class BasicAlterator implements Alterator {
 
     //gets the Ontology classes
     @SuppressWarnings("unchecked")
-    public List<OntClass> getOntologyClasses () {
+    public List<OntClass> getOntologyClasses() {
         List<OntClass> classes = new ArrayList<OntClass>();
         for ( Iterator it = modifiedModel.listNamedClasses(); it.hasNext(); ) {
             OntClass aux = (OntClass)it.next();
-            if ( aux.getNameSpace().equals( modifiedOntologyNS ) ) {
+	    // JE: why not startsWith ?
+            if ( getNameSpace( aux.getURI() ).equals( modifiedOntologyNS ) ) {
                 classes.add( aux );
             }
         }
@@ -232,11 +259,12 @@ public abstract class BasicAlterator implements Alterator {
 
     //gets the Ontology properties
     @SuppressWarnings("unchecked")
-    public List<OntProperty> getOntologyProperties () {
+    public List<OntProperty> getOntologyProperties() {
         List<OntProperty> properties = new ArrayList<OntProperty>();
         for ( Iterator it = modifiedModel.listAllOntProperties(); it.hasNext(); ) {
             OntProperty prop = (OntProperty)it.next();
-            if ( prop.getNameSpace().equals( modifiedOntologyNS ) )
+	    // JE: why not startsWith ?
+            if ( getNameSpace( prop.getURI() ).equals( modifiedOntologyNS ) )
                 properties.add( prop );
         }
         return properties;
@@ -305,25 +333,24 @@ public abstract class BasicAlterator implements Alterator {
 
     //removes a class, returns the uri of his parent
     @SuppressWarnings("unchecked")
-    public String removeClass ( OntClass cls ) {
-        OntClass parentClass;
+    public String removeClass( OntClass cls ) {
         ArrayList<OntClass> subClasses = new ArrayList<OntClass>();		//the list of all the subclasses of the class
         OntClass thing = modifiedModel.createClass( OWL.Thing.getURI() );	//Thing class
-        buildClassHierarchy();							//check if the class hierarchy is built
-        parentClass = this.classHierarchy.removeClass( modifiedModel, cls );//get the parent of the class
+        buildClassHierarchy();							//build the class hierarchy if necessary
+        OntClass parentClass = classHierarchy.removeClass( modifiedModel, cls );//get the parent of the class
 
-        for (Iterator it1 = cls.listSubClasses(); it1.hasNext(); ) {            //build the list of subclasses
+        for (Iterator it = cls.listSubClasses(); it.hasNext(); ) {            //build the list of subclasses
 	    //because we can't change the
-            subClasses.add( (OntClass)it1.next() );						//model while we are iterating
+            subClasses.add( (OntClass)it.next() );						//model while we are iterating
         }
 
         if ( parentClass != thing )						//now we change the superclass of classes
             for (OntClass clss : subClasses) 					//new superclass =>
                 clss.setSuperClass( parentClass );				//=>the superclass of the node
 
-	    checkClassesRestrictions( cls, parentClass );
-            cls.remove();							//remove the class from the Ontology
-            return parentClass.getURI();
+	checkClassesRestrictions( cls, parentClass );
+	cls.remove();							//remove the class from the Ontology
+	return parentClass.getURI();
     }
 
     //compute the alignment after the modifications
@@ -346,7 +373,7 @@ public abstract class BasicAlterator implements Alterator {
 
     public void relocateTest( String base1, String base2 ) {
         extractedAlignment = extractAlignment( base1, base2 );
-	modifiedModel = changeNamespace2( base2 );
+	modifiedModel = changeNamespace( base2 );
 	modifiedOntologyNS = base2;
     }
 
@@ -358,32 +385,22 @@ public abstract class BasicAlterator implements Alterator {
 	//System.err.println( "-----> "+base1 );
 	//System.err.println( "-----> "+base2 );
         try {
-            URI onto1 = new URI( base1.substring(0, base1.lastIndexOf("#")) );
-            URI onto2 = new URI( base2.substring(0, base2.lastIndexOf("#")) );
+            URI onto1 = new URI( getNameSpace( base1 ) );
+            URI onto2 = new URI( getNameSpace( base2 ) );
 
             extractedAlignment.init( onto1, onto2 );
 	    // JE: not likely correct
             extractedAlignment.setFile1( onto1 );
             extractedAlignment.setFile2( onto2 );
             
-	    int endBase = initOntologyNS.lastIndexOf("#")+1;
- 	    int endBase2 = base2.lastIndexOf("#")+1;
- 	    Properties newProp = new Properties();
             for ( String key : alignment.stringPropertyNames() ) {
-                String value = alignment.getProperty(key);
-		String source = key;
- 		// JE: This is useless in principle...
- 		if ( !key.startsWith( base1 ) ) {
-		    String fragment = key.substring( endBase );
-		    source = base1+fragment;
+		if ( !key.equals("##") ) {
+		    String value = alignment.getProperty(key);
+		    //if ( debug ) System.err.println( "[" + source + "][" + target + "]" );
+		    extractedAlignment.addAlignCell( URI.create( base1+key ), URI.create( base2+value ) );
 		}
-		// JE: not efficient certainly
-		String target = base2+value.substring( value.lastIndexOf("#")+1 );
-                //if ( debug ) System.err.println( "[" + source + "][" + target + "]" );
-                extractedAlignment.addAlignCell( URI.create( source ), URI.create( target ) );
-		newProp.put( source, target );
             }
-	    alignment = newProp;
+	    alignment.setProperty( "##", base1 );
         } catch ( Exception ex ) {  
 	    ex.printStackTrace();
         }
@@ -407,29 +424,19 @@ public abstract class BasicAlterator implements Alterator {
             Property predicate = stm.getPredicate();                            //the predicate
             RDFNode object     = stm.getObject();                               //the object
 
-            if ( ( subject.getLocalName() != null ) && ( !subject.isLiteral() )
-		 && ( subject.getNameSpace().equals( modifiedOntologyNS ) ) ) {
-		subject = newModel.createResource( ns + subject.getLocalName() );
+            if ( !subject.isLiteral() && ( subject.getURI() != null )
+		 && ( getNameSpace( subject.getURI() ).equals( modifiedOntologyNS ) ) ) {
+		subject = newModel.createResource( ns + getLocalName( subject.getURI() ) );
 	    }
             if ( !object.isLiteral() && ( object.canAs( Resource.class ) ) && ( object.isURIResource() )
-		 && ( object.asResource().getNameSpace().equals( modifiedOntologyNS ) ) ) {
-		object = newModel.createResource( ns + object.asResource().getLocalName() );
+		 && ( getNameSpace( object.asResource().getURI() ).equals( modifiedOntologyNS ) ) ) {
+		object = newModel.createResource( ns + getLocalName( object.asResource().getURI() ) );
 	    }
-            if ( !predicate.isLiteral() && ( predicate.getNameSpace().equals( modifiedOntologyNS ) ) ) {
-		predicate = newModel.createProperty( ns + predicate.getLocalName() );
+            if ( !predicate.isLiteral() && ( getNameSpace( predicate.getURI() ).equals( modifiedOntologyNS ) ) ) {
+		predicate = newModel.createProperty( ns + getLocalName( predicate.getURI() ) );
 	    }
 	    newModel.add( subject, predicate, object );
 	}
-
-	/*
-	  Ontology onto = newModel.getOntology( modifiedOntologyNS );
-	if ( onto == null ) { // Ugly but efficient
-	    for ( Ontology o : newModel.listOntologies().toList() ) {
-		onto = o;
-	    }
-	}
-	ResourceUtils.renameResource( onto, ns );
-	*/
 	renameOntology( newModel, modifiedOntologyNS, ns );
         return newModel;
     }
@@ -442,13 +449,8 @@ public abstract class BasicAlterator implements Alterator {
      * Two versions would be possible:
      * OntModel.write( OutputStream out ) / OntModel.write( Writer writer ) 
      * new Model().read( InputStream in, String base ) / new Model().read(Reader reader, String base)
-     * So far this is less efficient (and less correct) than the modifications above
-     * However, it solves a problem that has been observed in Jena:
-     * Jena does not like to have fragment identividers containing numbers! (and other combinations)
+     * So far this is less efficient (and less elegant) than the modifications above
      */
-
-    // At the moment, this is slower... and likely to be wrong...
-    // Why would it be wrong? It is however strange...
     public OntModel changeNamespace2( String base2 ) {
 	OntModel model = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
 	try {
diff --git a/src/fr/inrialpes/exmo/align/gen/alt/EmptyModification.java b/src/fr/inrialpes/exmo/align/gen/alt/EmptyModification.java
index af02be9802ca1f42284fad7dd9c4c634dcddf82d..6edcb0023162782a952a9081c6f90a0cba934995 100755
--- a/src/fr/inrialpes/exmo/align/gen/alt/EmptyModification.java
+++ b/src/fr/inrialpes/exmo/align/gen/alt/EmptyModification.java
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- * Copyright (C) 2011, INRIA
+ * Copyright (C) 2011-2012, INRIA
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -51,23 +51,31 @@ public class EmptyModification extends BasicAlterator {
     // Clearly here setDebug, setNamespace are important
 
     public Alterator modify( Properties params ) {
+	//System.err.println( "********************************************************************************************" );
 	relocateSource = ( params.getProperty( "copy101" ) != null );
 
 	if ( alignment == null ) {
 	    initOntologyNS = modifiedOntologyNS;
 
 	    alignment = new Properties();
+	    alignment.setProperty( "##", initOntologyNS );
 
+	    // Jena has a bug when URIs contain non alphabetical characters
+	    // in the localName, it does not split correctly ns/localname
 	    for ( OntClass cls : modifiedModel.listNamedClasses().toList() ) {
-		if ( cls.getNameSpace().equals( modifiedOntologyNS ) ) {
-		    String uri = cls.getURI();
-		    alignment.put( uri, uri ); //add them to the initial alignment
+		String uri = cls.getURI();
+		if ( uri.startsWith( modifiedOntologyNS ) ) {
+		    String ln = uri.substring( uri.lastIndexOf("#")+1 );
+		    //add them to the initial alignment
+		    if ( ln != null && !ln.equals("") )	alignment.put( ln, ln );
 		} 
 	    }
 	    for ( OntProperty prop : modifiedModel.listAllOntProperties().toList() ) {
-		if ( prop.getNameSpace().equals( modifiedOntologyNS ) ) {
-		    String uri = prop.getURI();
-		    alignment.put( uri, uri ); //add them to the initial alignment
+		String uri = prop.getURI();
+		if ( uri.startsWith( modifiedOntologyNS ) ) {
+		    String ln = uri.substring( uri.lastIndexOf("#")+1 );
+		    //add them to the initial alignment
+		    if ( ln != null && !ln.equals("") )	alignment.put( ln, ln );
 		}
 	    }
 	}
@@ -82,10 +90,7 @@ public class EmptyModification extends BasicAlterator {
     //the initial reference alignment
     public void initializeAlignment( Properties al ) {
         alignment = al;
-
-        Enumeration e = alignment.propertyNames();
-        String aux = (String)e.nextElement();
-        initOntologyNS = aux.substring(0, aux.lastIndexOf("#")+1);
+	initOntologyNS = al.getProperty( "##" );
     }
 
 }
diff --git a/src/fr/inrialpes/exmo/align/gen/alt/FlattenLevel.java b/src/fr/inrialpes/exmo/align/gen/alt/FlattenLevel.java
index 38d0b5a0aedefb7953d1f73ec5cd792c73d17cdf..632065fdbe7cf3e44f0c2e9b95271e3bd5caabdd 100755
--- a/src/fr/inrialpes/exmo/align/gen/alt/FlattenLevel.java
+++ b/src/fr/inrialpes/exmo/align/gen/alt/FlattenLevel.java
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- * Copyright (C) 2011, INRIA
+ * Copyright (C) 2011-2012, INRIA
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -42,17 +42,17 @@ public class FlattenLevel extends BasicAlterator {
     public Alterator modify( Properties params ) {
 	String p = params.getProperty( ParametersIds.LEVEL_FLATTENED );
 	if ( p == null ) return null;
-	// Should be an float casted in int!!!
+	// Should be a float cast in int!!!
 	int level = (int)Float.parseFloat( p );
-        int size;
-        boolean active = false;
         ArrayList<OntClass> levelClasses = new ArrayList<OntClass>();		//the list of classes from that level
         ArrayList<OntClass> parentLevelClasses = new ArrayList<OntClass>();	//the list of parent of the child classes from that level
         ArrayList<OntClass> superLevelClasses = new ArrayList<OntClass>();	//the list of parent of the parent classes from that level
         if ( level == 1 ) return this; //no change
         buildClassHierarchy();                                                  //check if the class hierarchy is built
-        active = classHierarchy.flattenClassHierarchy( modifiedModel, level, levelClasses, parentLevelClasses, superLevelClasses);
-        size = levelClasses.size();
+	//classHierarchy.printClassHierarchy();
+        classHierarchy.flattenClassHierarchy( modifiedModel, level, levelClasses, parentLevelClasses, superLevelClasses);
+	//classHierarchy.printClassHierarchy();
+        final int size = levelClasses.size();
 
         /* remove duplicates from list */
         HashMap<String, ArrayList<Restriction>> restrictions = new HashMap<String, ArrayList<Restriction>>();
@@ -81,7 +81,7 @@ public class FlattenLevel extends BasicAlterator {
                         restr.add(r);
                     if ( r.isSomeValuesFromRestriction() )
                         restr.add(r);
-                    //if ( debug ) System.err.println( cls.getURI() + cls.getLocalName() );
+                    //if ( debug ) System.err.println( cls.getURI() );
                 }
             }
             //if ( debug ) System.err.println( restr.size() );
@@ -91,34 +91,19 @@ public class FlattenLevel extends BasicAlterator {
             }
             parentURI.add( parentClass.getURI() );
 
-            //all the classes are subclasses of owl: Thing
-            if (  active ) {                                                    //if ( !parentClass.getURI().equals( "Thing" ) ) {
-               OntClass superClass = superLevelClasses.get( i );                //parent class of the child class parents
-
-               //if ( debug ) System.err.println("SuperClass class [" + superClass.getURI() + "]");
-               //if ( debug ) System.err.println("Parent class [" + parentClass.getURI() + "]");
-               //if ( debug ) System.err.println("Child class [" + childClass.getURI() + "]");
-               
-               if ( modifiedModel.containsResource(parentClass) ) {
-                   //to check if the class appears as unionOf, someValuesFrom, allValuesFrom ..
-                   unionOf.put(parentClass.getURI(), superClass.getURI());
-                   checkClassesRestrictions ( parentClass, superClass );
-                   parentClass.remove();
-               }
-               childClass.addSuperClass( superClass );
-               parentClass.removeSubClass( childClass );
-            } else {
-                OntClass superClass = modifiedModel.createClass( OWL.Thing.getURI() );	//Thing class
-
-                if ( modifiedModel.containsResource(parentClass) ) {
-                   //to check if the class appears as unionOf..
-                   unionOf.put(parentClass.getURI(), superClass.getURI());
-                   checkClassesRestrictions ( parentClass, superClass );
-                   parentClass.remove();
-               }
-
-                parentClass.removeSubClass( childClass );
-            }            
+	    OntClass superClass = superLevelClasses.get( i );                //parent class of the child class parents
+	    if ( superClass == null ) superClass = modifiedModel.createClass( OWL.Thing.getURI() );	//Thing class
+	    //if ( debug ) System.err.println("SuperClass class [" + superClass.getURI() + "]");
+	    //if ( debug ) System.err.println("Parent class [" + parentClass.getURI() + "]");
+	    //if ( debug ) System.err.println("Child class [" + childClass.getURI() + "]");
+	    if ( modifiedModel.containsResource( parentClass ) ) {
+		//to check if the class appears as unionOf, someValuesFrom, allValuesFrom ..
+		unionOf.put( parentClass.getURI(), superClass.getURI() );
+		checkClassesRestrictions( parentClass, superClass );
+		parentClass.remove();
+	    }
+	    if ( superLevelClasses.get( i ) != null ) childClass.addSuperClass( superClass );
+	    parentClass.removeSubClass( childClass );
         }
 
         int i = 0;
@@ -138,10 +123,11 @@ public class FlattenLevel extends BasicAlterator {
 	int baselength = initOntologyNS.length(); // key.indexOf+baselenght == baselenght...
         for ( String key : alignment.stringPropertyNames() ) {
             String value = alignment.getProperty( key );
-            if ( parentURI.contains( modifiedOntologyNS + key.substring( key.indexOf( initOntologyNS ) + baselength) ) ) {        //this.classHierarchy.removeUri("Thing", key);
+            if ( parentURI.contains( modifiedOntologyNS + key ) ) {        //this.classHierarchy.removeUri("Thing", key);
                 alignment.remove( key );
             }
-            if ( parentURI.contains( modifiedOntologyNS + value.substring( key.indexOf( initOntologyNS ) + baselength ))) {    //this.classHierarchy.removeUri("Thing", value);
+		// This is strange
+            if ( parentURI.contains( modifiedOntologyNS + value ) ) {    //this.classHierarchy.removeUri("Thing", value);
                 alignment.remove( key );
             }
         }
diff --git a/src/fr/inrialpes/exmo/align/gen/alt/RemoveClassLevel.java b/src/fr/inrialpes/exmo/align/gen/alt/RemoveClassLevel.java
index a0f1c08d66b6210c50adbb473d520824079a776e..c38b5d22c7b34e5a4f92bfae1b69aaee8ec3fa31 100755
--- a/src/fr/inrialpes/exmo/align/gen/alt/RemoveClassLevel.java
+++ b/src/fr/inrialpes/exmo/align/gen/alt/RemoveClassLevel.java
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- * Copyright (C) 2011, INRIA
+ * Copyright (C) 2011-2012, INRIA
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -42,17 +42,12 @@ public class RemoveClassLevel extends BasicAlterator {
 	if ( p == null ) return null;
 	int level = Integer.parseInt( p );
         HashMap<String, String> uris = new HashMap<String, String>();
-        String parentURI = "";
         //if ( debug ) System.err.println( "Level " + level );
-        /*	if ( level == 1 )						//except classes from level 1
-         return;	*/
-        List<OntClass> classes = new ArrayList<OntClass>();
-        buildClassHierarchy();							//check if the class hierarchy is built
-        classes = this.classHierarchy.getClassesFromLevel(modifiedModel, level);
-        for ( int i=0; i<classes.size(); i++ ) {                                //remove the classes from the hierarchy
-            parentURI = removeClass ( classes.get(i) );
-            uris.put(classes.get(i).getURI(), parentURI);
-        }
+        buildClassHierarchy();							//build the class hierarchy if necessary
+	for ( OntClass cl : classHierarchy.getClassesFromLevel( modifiedModel, level ) ) {                                //remove the classes from the hierarchy
+            String parentURI = removeClass( cl );
+            uris.put( cl.getURI(), parentURI );
+	}
         //checks if the class appears like unionOf .. and replaces its appearence with the superclass
         modifiedModel = changeDomainRange( uris );
 	return this; // useless
diff --git a/src/fr/inrialpes/exmo/align/gen/alt/RemoveClasses.java b/src/fr/inrialpes/exmo/align/gen/alt/RemoveClasses.java
index ffc83d066498ff1ccae722cb8f93d9f107d7e47b..beced885dc8ae8e095e446437cd4832e917f5778 100755
--- a/src/fr/inrialpes/exmo/align/gen/alt/RemoveClasses.java
+++ b/src/fr/inrialpes/exmo/align/gen/alt/RemoveClasses.java
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- * Copyright (C) 2011, INRIA
+ * Copyright (C) 2011-2012, INRIA
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -45,22 +45,21 @@ public class RemoveClasses extends BasicAlterator {
         List<OntClass> removedClasses = new ArrayList<OntClass>();
         List<String> cl = new ArrayList<String>();
         HashMap<String, String> uris = new HashMap<String, String>();           //the HashMap of strings
-        String parentURI = "";
         int nbClasses = classes.size();						//number of classes
-        buildClassHierarchy();							//check if the class hierarchy is built
+        buildClassHierarchy();							//build the class hierarchy if necessary
         int toBeRemoved =  Math.round(percentage*nbClasses);			//the number of classes to be removed
 
         //build the list of classes to be removed
-        int [] n = this.randNumbers(nbClasses, toBeRemoved);
+        int [] n = this.randNumbers( nbClasses, toBeRemoved );
         for ( int i=0; i<toBeRemoved; i++ ) {
             OntClass cls = classes.get(n[i]);
             removedClasses.add( cls );
-            cl.add( cls.getURI() );                                             //builds the list of labels of classes to be removed
+            cl.add( getLocalName( cls.getURI() ) );                             //builds the list of labels of classes to be removed
         }
 
         for ( OntClass cls : removedClasses ) {					//remove the classes from the list
-            parentURI = removeClass (cls);
-            uris.put(cls.getURI(), parentURI);
+            String parentURI = removeClass( cls );
+            uris.put( cls.getURI(), parentURI );
         }
 
         //checks if the class appears like unionOf.. and replaces its appearence with the superclass
diff --git a/src/fr/inrialpes/exmo/align/gen/alt/RemoveIndividuals.java b/src/fr/inrialpes/exmo/align/gen/alt/RemoveIndividuals.java
index c564ac57f74a4aaa88ae260c1b63950e265daf0c..0feec64e7039e4d645f5dd21b28a6bc714aafbdd 100755
--- a/src/fr/inrialpes/exmo/align/gen/alt/RemoveIndividuals.java
+++ b/src/fr/inrialpes/exmo/align/gen/alt/RemoveIndividuals.java
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- * Copyright (C) 2011, INRIA
+ * Copyright (C) 2011-2012, INRIA
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -54,7 +54,7 @@ public class RemoveIndividuals extends BasicAlterator {
         for ( int i=0; i<toBeRemoved; i++ ) {
             Individual indiv = individuals.get(n[i]);				//remove the individual from the reference alignment
             individualsTo.add( indiv );
-            //alignment.remove( indiv.getURI() );
+            //alignment.remove( getLocalName( indiv.getURI() ) );
         }
 
         for ( Statement st : modifiedModel.listStatements().toList() ) {
diff --git a/src/fr/inrialpes/exmo/align/gen/alt/RemoveProperties.java b/src/fr/inrialpes/exmo/align/gen/alt/RemoveProperties.java
index a8b00bdac66887ccf446956cb31baa1ec3536c6b..aa48abb3f4ef685b02bebe984d681a859399b830 100755
--- a/src/fr/inrialpes/exmo/align/gen/alt/RemoveProperties.java
+++ b/src/fr/inrialpes/exmo/align/gen/alt/RemoveProperties.java
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- * Copyright (C) 2011, INRIA
+ * Copyright (C) 2011-2012, INRIA
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -67,7 +67,7 @@ public class RemoveProperties extends BasicAlterator {
         for ( int i=0; i<toBeRemoved; i++ ) {					//build the list of properties to be removed
             OntProperty property = properties.get( n[i] );
             propertiesToBeRemoved.add( property );
-            pr.add( property.getURI() );
+            pr.add( getLocalName( property.getURI() ) );
 
             //alignment.remove( p.getURI() );
 	    //get the restrictions of that property
@@ -115,16 +115,16 @@ public class RemoveProperties extends BasicAlterator {
             isSubj = isPred = isObj = false;
 
             if ( propertiesToBeRemoved.contains( subject ) )			//if appears as subject
-                if ( subject.getNameSpace().equals( modifiedOntologyNS ) )
+                if ( getNameSpace( subject.getURI() ).equals( modifiedOntologyNS ) )
                     isSubj = true;
 
             if ( propertiesToBeRemoved.contains( predicate ) )			//if appears as predicate
-                if ( predicate.getNameSpace().equals( modifiedOntologyNS ) )
+                if ( getNameSpace( predicate.getURI() ).equals( modifiedOntologyNS ) )
                     isPred = true;
 
             if ( object.canAs( Resource.class ) )				//if appears as object
                 if ( propertiesToBeRemoved.contains( object ) )
-                    if ( object.asResource().getNameSpace().equals( modifiedOntologyNS ) )
+                    if ( getNameSpace( object.asResource().getURI() ).equals( modifiedOntologyNS ) )
                         isObj = true;
 
             if ( isSubj || isPred || isObj )					//remove the statement in which the prop
diff --git a/src/fr/inrialpes/exmo/align/gen/alt/RenameClasses.java b/src/fr/inrialpes/exmo/align/gen/alt/RenameClasses.java
index f52bd1ce1d16f6777ea6e8922cbaf789769cf6f9..d81657d2a0ceecc01fb9241a87e371e0c8c8e7b9 100755
--- a/src/fr/inrialpes/exmo/align/gen/alt/RenameClasses.java
+++ b/src/fr/inrialpes/exmo/align/gen/alt/RenameClasses.java
@@ -40,7 +40,7 @@ public class RenameClasses extends RenameThings {
 	String p = params.getProperty( ParametersIds.RENAME_CLASSES );
 	if ( p == null ) return null;
 	float percentage = Float.parseFloat( p );
-	modifiedModel = renameResource ( false, true, percentage, true, false, false, 0);
+	modifiedModel = renameResource( false, true, percentage, true, false, false, 0 );
 	return this; // useless
     };
 
diff --git a/src/fr/inrialpes/exmo/align/gen/alt/RenameThings.java b/src/fr/inrialpes/exmo/align/gen/alt/RenameThings.java
index 044b409b3fbbc76d47910ba98533a549e4b5fc76..72c83853204800d0466eca45737bebb9cdf3f2d1 100755
--- a/src/fr/inrialpes/exmo/align/gen/alt/RenameThings.java
+++ b/src/fr/inrialpes/exmo/align/gen/alt/RenameThings.java
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- * Copyright (C) 2011, INRIA
+ * Copyright (C) 2011-2012, INRIA
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -88,10 +88,9 @@ public abstract class RenameThings extends BasicAlterator {
 
         // build the list of all unrenamed properties from the model
         for ( OntProperty p : properties ) {
-	    String local = p.getLocalName();
-            String uri = initOntologyNS+local;
-            if ( alignment.containsKey( uri ) ) {
-                if ( alignment.getProperty( uri ).equals( modifiedOntologyNS+local ) )
+	    String local = getLocalName( p.getURI() );
+            if ( alignment.containsKey( local ) ) {
+                if ( alignment.getProperty( local ).equals( local ) )
                     notRenamedProperties.add( p );      //add the property to not renamed properties  
             }
         }
@@ -107,13 +106,13 @@ public abstract class RenameThings extends BasicAlterator {
 	for ( int i=0; i<toBeRenamed; i++ ) {
 		OntProperty p = notRenamedProperties.get(n[i]);
 		propertiesTo.add(p);
-                if ( p.getNameSpace().equals( modifiedOntologyNS ) ) 
-                    propertiesName.add( p.getLocalName() );
+                if ( getNameSpace( p.getURI() ).equals( modifiedOntologyNS ) ) 
+                    propertiesName.add( getLocalName( p.getURI() ) );
 	}
 
 	for ( OntProperty prop : propertiesTo ) {
-		String prefix = prop.getNameSpace();
-		String localName = prop.getLocalName();
+	    String prefix = getNameSpace( prop.getURI() );
+		String localName = getLocalName( prop.getURI() );
 		//has the same Namespace as the Ontology Namespace
                 if ( prefix.equals( modifiedOntologyNS ) ) {
                     if ( !propertiesIdentifiers.containsKey( localName ) ) {
@@ -122,15 +121,15 @@ public abstract class RenameThings extends BasicAlterator {
                             propertiesIdentifiers.put( localName , translateStrg );
                             replacePropertyLabel( prop.getURI(), translateStrg, activeRandomString, activeTranslateString, activeSynonym, activeStringOperation );
 
-                            if ( alignment.containsKey( initOntologyNS + prop.getLocalName() ) ) {        //alignment.remove( prop.getURI() );
-                                alignment.put( initOntologyNS + prop.getLocalName() , initOntologyNS + translateStrg );//the reference alignment
+                            if ( alignment.containsKey( localName ) ) {        //alignment.remove( prop.getURI() );
+                                alignment.put( localName, translateStrg );//the reference alignment
                             }
                         } else if ( activeRandomString ) {                        //replace the URI with a random string
                             String newStrg = getRandomString();
                             propertiesIdentifiers.put( localName , newStrg );
                             replacePropertyLabel( prop.getURI(), newStrg, activeRandomString, activeTranslateString, activeSynonym, activeStringOperation );
-                            if ( alignment.containsKey( initOntologyNS + prop.getLocalName() ) ) {        //alignment.remove( prop.getURI() );
-                                alignment.put( initOntologyNS + prop.getLocalName() , initOntologyNS + newStrg);//the reference alignment
+                            if ( alignment.containsKey( localName ) ) {        //alignment.remove( prop.getURI() );
+                                alignment.put( localName, newStrg);//the reference alignment
                             }
                         } else if ( activeSynonym ) {
                             String synonym = parseString (localName, false, true);
@@ -139,27 +138,27 @@ public abstract class RenameThings extends BasicAlterator {
                             else  {
                                 propertiesIdentifiers.put( localName, synonym );
                                 replacePropertyLabel( prop.getURI(), synonym, activeRandomString, activeTranslateString, activeSynonym, activeStringOperation );
-                                if ( alignment.containsKey( initOntologyNS + prop.getLocalName() ) ) {    //alignment.remove( prop.getURI() );
-                                    alignment.put( initOntologyNS + prop.getLocalName() , initOntologyNS + synonym );	//the reference alignment
+                                if ( alignment.containsKey( localName ) ) {    //alignment.remove( prop.getURI() );
+                                    alignment.put( localName, synonym );	//the reference alignment
                                 }
                             }
                         } else if ( activeStringOperation == 1 ) {                //replace the URI with the UpperCase URI
                             propertiesIdentifiers.put( localName , localName.toUpperCase() );
                             replacePropertyLabel( prop.getURI(), localName.toUpperCase(), activeRandomString, activeTranslateString, activeSynonym, activeStringOperation );
-                            if ( alignment.containsKey( initOntologyNS + prop.getLocalName() ) ) {        //alignment.remove( prop.getURI() );
-                                alignment.put( initOntologyNS + prop.getLocalName() , initOntologyNS + localName.toUpperCase() ); //the reference alignment
+                            if ( alignment.containsKey( localName ) ) {        //alignment.remove( prop.getURI() );
+                                alignment.put( localName, localName.toUpperCase() ); //the reference alignment
                             }
                         } else if ( activeStringOperation == 2 ) {
                             propertiesIdentifiers.put( localName , localName.toLowerCase() );
                             replacePropertyLabel( prop.getURI(), localName.toLowerCase(), activeRandomString, activeTranslateString, activeSynonym, activeStringOperation );
-                            if ( alignment.containsKey( initOntologyNS + prop.getLocalName() ) ) {        // alignment.remove( prop.getURI() );
-                                alignment.put( initOntologyNS + prop.getLocalName() , initOntologyNS + localName.toLowerCase() ); //the reference alignment
+                            if ( alignment.containsKey( localName ) ) {        // alignment.remove( prop.getURI() );
+                                alignment.put( localName, localName.toLowerCase() ); //the reference alignment
                             }
                         } else {
                             propertiesIdentifiers.put( localName,  localName + "PROPERTY" );
                             replacePropertyLabel( prop.getURI(), localName + "PROPERTY", activeRandomString, activeTranslateString, activeSynonym, activeStringOperation );
-                            if ( alignment.containsKey( initOntologyNS + prop.getLocalName() ) ) {        //alignment.remove( prop.getURI() );
-                                alignment.put( initOntologyNS + prop.getLocalName() , initOntologyNS + localName + "PROPERTY" );
+                            if ( alignment.containsKey( localName ) ) {        //alignment.remove( prop.getURI() );
+                                alignment.put( localName, localName + "PROPERTY" );
                             }
                         }
                     }
@@ -192,12 +191,10 @@ public abstract class RenameThings extends BasicAlterator {
 
 	// alignment contains those classes which have already been renamed
         //builds the list of all unrenamed classes from the model
-	// JE: All these operations are very expensive (be better with either no namespace or alignment)
         for ( OntClass c : classes ) {
-	    String local = c.getLocalName();
-            String uri = initOntologyNS + local;
-            if ( alignment.containsKey( uri ) ) {
-                if ( alignment.getProperty( uri ).equals( modifiedOntologyNS+local ) )
+	    String local = getLocalName( c.getURI() );
+            if ( alignment.containsKey( local ) ) {
+                if ( alignment.getProperty( local ).equals( local ) )
                     notRenamedClasses.add( c ); //add the class to not renamed classes
             }
         }
@@ -220,8 +217,8 @@ public abstract class RenameThings extends BasicAlterator {
         for ( OntClass cls : classesTo ) {
             if ( !cls.isRestriction() ) {
                 if ( !cls.isAnon() ) {
-                    String prefix = cls.getNameSpace();
-                    String localName = cls.getLocalName();
+                    String prefix = getNameSpace( cls.getURI() );
+                    String localName = getLocalName( cls.getURI() );
 
                     //has the same Namespace as the Ontology Namespace
                     if ( prefix.equals( modifiedOntologyNS ) ) {
@@ -230,40 +227,40 @@ public abstract class RenameThings extends BasicAlterator {
                                 String translateStrg = parseString (localName, true, false);
                                 classesIdentifiers.put( localName , translateStrg );
                                 replaceClassLabel( cls.getURI(), translateStrg, activeRandomString, activeTranslateString, activeSynonym, activeStringOperation );
-                                if ( alignment.containsKey( initOntologyNS + cls.getLocalName() ) ) {     //alignment.remove( cls.getURI() );
-                                    alignment.put( initOntologyNS + cls.getLocalName() , initOntologyNS + translateStrg);	//the reference alignment
+                                if ( alignment.containsKey( localName ) ) {     //alignment.remove( cls.getURI() );
+                                    alignment.put( localName, translateStrg);	//the reference alignment
                                 }
                             } else if ( activeRandomString )	{		//replace the URI with a random string
                                 String newStrg = getRandomString();
                                 classesIdentifiers.put( localName , newStrg );
                                 replaceClassLabel( cls.getURI(), newStrg, activeRandomString, activeTranslateString, activeSynonym, activeStringOperation );
-                                if ( alignment.containsKey( initOntologyNS + cls.getLocalName() ) ) {     //alignment.remove( cls.getURI() );
-                                    alignment.put( initOntologyNS + cls.getLocalName() , initOntologyNS + newStrg );	//the reference alignment
+                                if ( alignment.containsKey( localName ) ) {     //alignment.remove( cls.getURI() );
+                                    alignment.put( localName, newStrg );	//the reference alignment
                                 }
                             } else if ( activeSynonym ) {                         //replace the URI with a synonym
                                 String synonym = parseString (localName, false, true);
 				classesIdentifiers.put( localName, synonym );
 				replaceClassLabel( cls.getURI(), synonym, activeRandomString, activeTranslateString, activeSynonym, activeStringOperation );
-				if ( alignment.containsKey( initOntologyNS + cls.getLocalName() ) ) {     //alignment.remove( cls.getURI() );
-                                    alignment.put( initOntologyNS + cls.getLocalName() , initOntologyNS + synonym );//the reference alignment
+				if ( alignment.containsKey( localName ) ) {     //alignment.remove( cls.getURI() );
+                                    alignment.put( localName, synonym );//the reference alignment
                                 }
                             } else if ( activeStringOperation == 1 ){             //replace the URI with the UpperCase URI
                                 classesIdentifiers.put( localName , localName.toUpperCase() );
                                 replaceClassLabel( cls.getURI(), localName.toUpperCase(), activeRandomString, activeTranslateString, activeSynonym, activeStringOperation );
-                                if ( alignment.containsKey( initOntologyNS + cls.getLocalName() ) ) {     //alignment.remove( cls.getURI() );
-                                    alignment.put( initOntologyNS + cls.getLocalName() , initOntologyNS + localName.toUpperCase() ); //the reference alignment
+                                if ( alignment.containsKey( localName ) ) {     //alignment.remove( cls.getURI() );
+                                    alignment.put( localName, localName.toUpperCase() ); //the reference alignment
                                 }
                             } else if ( activeStringOperation == 2 ){             //replace the URI with the LowerCase URI
                                 classesIdentifiers.put( localName , localName.toLowerCase() );
                                 replaceClassLabel( cls.getURI(), localName.toLowerCase(), activeRandomString, activeTranslateString, activeSynonym, activeStringOperation );
-                                if ( alignment.containsKey( initOntologyNS + cls.getLocalName() ) ) {     //alignment.remove( cls.getURI() );
-                                    alignment.put( initOntologyNS + cls.getLocalName() , initOntologyNS + localName.toLowerCase() );     //the reference alignment
+                                if ( alignment.containsKey( localName ) ) {     //alignment.remove( cls.getURI() );
+                                    alignment.put( localName, localName.toLowerCase() );     //the reference alignment
                                 }
                             } else {
                                 classesIdentifiers.put( localName, localName + "CLASS" );
                                 replaceClassLabel( cls.getURI(), localName + "CLASS", activeRandomString, activeTranslateString, activeSynonym, activeStringOperation );
-                                if ( alignment.containsKey( initOntologyNS + cls.getLocalName() ) ) {     //alignment.remove( cls.getURI() );
-                                    alignment.put( initOntologyNS + cls.getLocalName() , initOntologyNS + localName + "CLASS" );
+                                if ( alignment.containsKey( localName ) ) {     //alignment.remove( cls.getURI() );
+                                    alignment.put( localName, localName + "CLASS" );
                                 }
                             }
                         }
@@ -277,7 +274,7 @@ public abstract class RenameThings extends BasicAlterator {
     //renames percentage properties and classes
     //activeProperties -> if true, then rename properties
     //activeClasses -> if true, then rename classes
-    public OntModel renameResource ( boolean activeProperties, boolean activeClasses, float percentage, boolean activeRandomString, boolean activeTranslateString, boolean activeSynonym, int activeStringOperation) {
+    public OntModel renameResource( boolean activeProperties, boolean activeClasses, float percentage, boolean activeRandomString, boolean activeTranslateString, boolean activeSynonym, int activeStringOperation) {
         List<Statement> statements = null;                                      //the list of all statements
         HashMap<String, String> propertiesIdentifiers = null;                   //the HashMap of the properties identifiers
         HashMap<String, String> classesIdentifiers = null;                      //the HashMap of the classes identifiers
@@ -296,39 +293,31 @@ public abstract class RenameThings extends BasicAlterator {
             Property predicate = stm.getPredicate();                            //the predicate
             RDFNode object     = stm.getObject();                               //the object
 
-	    String subjectLocalName,   subjectNameSpace;
-	    String predicateLocalName, predicateNameSpace;
-	    String objectLocalName,    objectNameSpace;
-	    
 	    boolean isPred, isSubj, isObj;
-
-            Resource subj = null;
-            Property pred = null;
-            Resource obj  = null;
             isPred = isSubj = isObj = false;
 
+	    String subjuri = subject.getURI();
+	    String subjectLocalName = getLocalName( subjuri );
+            Resource subj = null;
             //if it is the subject of the statement
-            if ( subject.getLocalName() != null ) {
+            if ( subjectLocalName != null ) {
+	        String subjectNameSpace = getNameSpace( subjuri );
                 if ( activeProperties ) {
-                    if ( propertiesIdentifiers.containsKey( subject.getLocalName() ) ) {
+                    if ( propertiesIdentifiers.containsKey( subjectLocalName ) ) {
                         //if the namespace of the subject is the same as the namespace of the property identifier
-                        if ( subject.getNameSpace().equals( modifiedOntologyNS ) ) {//that we want to remove
+                        if ( subjectNameSpace.equals( modifiedOntologyNS ) ) {//that we want to remove
                             isSubj = true;
-                            subjectNameSpace = subject.getNameSpace();
-                            subjectLocalName = subject.getLocalName();
                             subj = newModel.createResource( subjectNameSpace + propertiesIdentifiers.get( subjectLocalName ) );
                         }
                     }
                 }
 
                 if ( activeClasses ) {
-                    if ( classesIdentifiers.containsKey( subject.getLocalName() ) ) {
+                    if ( classesIdentifiers.containsKey( subjectLocalName ) ) {
                         //if the namespace of the subject is the same as the namespace of the property identifier
                        //that we want to remove
-                        if (subject.getNameSpace().equals( modifiedOntologyNS ) ) {
+                        if ( subjectNameSpace.equals( modifiedOntologyNS ) ) {
                             isSubj = true;
-                            subjectNameSpace = subject.getNameSpace();
-                            subjectLocalName = subject.getLocalName();
                             subj = newModel.createResource( subjectNameSpace + classesIdentifiers.get( subjectLocalName ) );
                         }
                     }
@@ -336,55 +325,55 @@ public abstract class RenameThings extends BasicAlterator {
             }
 
             //if it is the predicate of the statement
+	    String preduri =  predicate.getURI();
+	    String predicateLocalName = getLocalName( preduri );
+	    String predicateNameSpace = getNameSpace( preduri );
+            Property pred = null;
             if ( activeProperties ) {
-                if ( propertiesIdentifiers.containsKey( predicate.getLocalName() ) ) {
+		    if ( propertiesIdentifiers.containsKey( predicateLocalName ) ) {
                     //if the namespace of the predicate is the same as the namespace of the property identifier
                     //that we want to remove
-                    if ( predicate.getNameSpace().equals( modifiedOntologyNS ) ) {
+                    if ( predicateNameSpace.equals( modifiedOntologyNS ) ) {
                         isPred = true;
-                        predicateNameSpace = predicate.getNameSpace();
-                        predicateLocalName = predicate.getLocalName();
                         pred = newModel.createProperty(predicateNameSpace, propertiesIdentifiers.get( predicateLocalName ) );
                     }
                 }
             }
 
             if ( activeClasses ) {
-                if ( classesIdentifiers.containsKey( predicate.getLocalName() ) ) {
+                if ( classesIdentifiers.containsKey( predicateLocalName ) ) {
                     //if the namespace of the predicate is the same as the namespace of the property identifier
                     //that we want to remove
-                    if ( predicate.getNameSpace().equals( modifiedOntologyNS ) ) {
+                    if ( predicateNameSpace.equals( modifiedOntologyNS ) ) {
                         isPred = true;
-                        predicateNameSpace = predicate.getNameSpace();
-                        predicateLocalName = predicate.getLocalName();
                         pred = newModel.createProperty(predicateNameSpace, classesIdentifiers.get( predicateLocalName ) );
                     }
                 }
             }
             
+            Resource obj  = null;
             //if it is the object of the statement
             if ( object.canAs( Resource.class ) )
                 if ( object.isURIResource() ) {
+		    String uri =  object.asResource().getURI();
+		    String objectLocalName = getLocalName( uri );
+		    String objectNameSpace = getNameSpace( uri );
                     if ( activeProperties ) {
-                        if ( propertiesIdentifiers.containsKey( object.asResource().getLocalName() ) ) {
+                        if ( propertiesIdentifiers.containsKey( objectLocalName ) ) {
                             //if the namespace of the object is the same as the namespace of the property identifier
                             //that we want to remove
-                            if ( object.asResource().getNameSpace().equals( modifiedOntologyNS ) ) {
+                            if ( objectNameSpace.equals( modifiedOntologyNS ) ) {
                                 isObj = true;
-                                objectNameSpace = object.asResource().getNameSpace();
-                                objectLocalName = object.asResource().getLocalName();
                                 obj = newModel.createResource(objectNameSpace + propertiesIdentifiers.get( objectLocalName ) );
                             }
                         }
                     }
 
                     if ( activeClasses ) {
-                        if ( classesIdentifiers.containsKey( object.asResource().getLocalName() ) ) {
+                        if ( classesIdentifiers.containsKey( objectLocalName ) ) {
                             //if the namespace of the object is the same as the namespace of the property identifier that we want to remove
-                            if ( object.asResource().getNameSpace().equals( modifiedOntologyNS ) ) {
+                            if ( objectNameSpace.equals( modifiedOntologyNS ) ) {
                                 isObj = true;
-                                objectNameSpace = object.asResource().getNameSpace();
-                                objectLocalName = object.asResource().getLocalName();
                                 obj = newModel.createResource(objectNameSpace + classesIdentifiers.get( objectLocalName ) );
                             }
                         }
diff --git a/src/fr/inrialpes/exmo/align/gen/alt/SuppressHierarchy.java b/src/fr/inrialpes/exmo/align/gen/alt/SuppressHierarchy.java
index de9971dac00686c4a3d31512cb3b19aa4f159ce7..1f71b69d269217518a82a9439ffd947887810f2b 100755
--- a/src/fr/inrialpes/exmo/align/gen/alt/SuppressHierarchy.java
+++ b/src/fr/inrialpes/exmo/align/gen/alt/SuppressHierarchy.java
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- * Copyright (C) 2011, INRIA
+ * Copyright (C) 2011-2012, INRIA
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -51,26 +51,22 @@ public class SuppressHierarchy extends BasicAlterator {
     // flatten level
     public void noHierarchy ( int level ) {
         if ( level == 1 ) return;
-        int size;
-        boolean active = false;
         ArrayList<OntClass> levelClasses = new ArrayList<OntClass>();		//the list of classes from that level
         ArrayList<OntClass> parentLevelClasses = new ArrayList<OntClass>();	//the list of parent of the child classes from that level
         ArrayList<OntClass> superLevelClasses = new ArrayList<OntClass>();	//the list of parent of the parent classes from that level
         buildClassHierarchy();                                                  //check if the class hierarchy is built
-        active = this.classHierarchy.flattenClassHierarchy( modifiedModel, level, levelClasses, parentLevelClasses, superLevelClasses);
-        size = levelClasses.size();
+        classHierarchy.flattenClassHierarchy( modifiedModel, level, levelClasses, parentLevelClasses, superLevelClasses);
+        int size = levelClasses.size();
 
         for ( int i=0; i<size; i++ ) {
             OntClass childClass = levelClasses.get( i );			//child class
             OntClass parentClass = parentLevelClasses.get( i );                 //parent class
             //all the classes are subclasses of owl: Thing
-            if (  active ) {                                                    //if ( !parentClass.getURI().equals( "Thing" ) ) {
-               OntClass superClass = superLevelClasses.get( i );                //parent class of the child class parents
+	    OntClass superClass = superLevelClasses.get( i );                //parent class of the child class parents
+            if ( superClass != null ) {                                                    //if ( !parentClass.getURI().equals( "Thing" ) ) {
                childClass.addSuperClass( superClass );
-               parentClass.removeSubClass( childClass );
-            } else {
-                parentClass.removeSubClass( childClass );
             }
+	    parentClass.removeSubClass( childClass );
         }
     }