Some fixes for python3 script