Fix python shell, fix crash on exit

Two fixes: 
1) pyshell would not start
2) PyFinalize() would crash

also misc cleanup