hyperedge support and some refactoring