Added the getInstance and terminateInstance functions but did not hook t...

...hem up yet. Also added some functionality to set the debug flag if there is any value in it, it remains untested but will not fail the program so I included it in the merge.