ptext: some refactoring