Added Core to winmain

added memory leak detection, and exception handling.