I neglected FreeLibrary and have multiple calls to LoadLibrary without freeing. This is fixed by moving it to the class member level and allocating and deallocating through the class constructor/destructor.
threading code needs some refactoring. List of changes:
* Script threads no longer call the debugger UI (e.g. refresh) nor do
they call the script system's cleanup function
(deleteStoppedInstances).
* Changed API.js Server.on method to queue calls to nativeAccept if .listen()
hasn't been called yet (otherwise winsock gives errors).
* Added various paranoia thread locks.
* Forced termination of script threads now works. The (commented) call
to TerminateThread didn't work because getCurrentThread() doesn't return
a "real" HANDLE. The solution is to pass the result of getCurrentThread
to DuplicateHandle to get a "real" handle.