Fixed some bugs in the python