fixed some bugs in python scripts