Fixed some Python bugs