Moved the coinitialize and uninitialize code to main
Fixes resolution changing