Refactor pgraph stuff

So much pep8!