Implemented removal of hierarchies, fixed some bugs, see #36

When an hierarchie is removed, all of the hierarchies that directly or indirectly reference it are removed as well. Fixed a few minor bugs.