Fixed Pdata so that it's possible to use the script on a headless machine.