Fixed some python bugs