Refactored graph loading