Fixed some crashes with python scripts