Refactoring, implement reference registry, fix graph copy constructor.