Moved python init and shutdown