Various fixes to allow PyInstaller to work