Fixed bugs in portdata.py