a lot of refactoring in pdu.py