Hopefully solved the problems with Python and multithreading.

Solution: release GIL on startup, make sure that all our call to Python
API acquire and then release GIL again (calls from SIP are safe, too).
Ported from Martin's dev-threading branch.