Some refactoring on PEP