fix bugs in ps.py, bsmf.py. Tested.