pdl.py: more refactoring