Improve p_* functions in smtio.py