Refactor graph package