Refactoring and graph generation