Refactor pwrequest.py