ppr and some refactoring