Refactor graph manager