Index: /trunk/FACT++/src/InterpreterV8.cc
===================================================================
--- /trunk/FACT++/src/InterpreterV8.cc	(revision 14601)
+++ /trunk/FACT++/src/InterpreterV8.cc	(revision 14602)
@@ -40,9 +40,18 @@
 // termination. Therefor a list of V8 thread ids is created.
 //
-// If temrination has already be signalled, no thread should start running
+// If termination has already be signalled, no thread should start running
 // anymore (thy could, e.g., wait for their locking). So after locking
 // it has to be checked if the thread was terminated already. Note
 // that all calls to Terminate() must be locked to ensure that fThreadId
 // is correct when it is checked.
+//
+// The current thread id must be added to fThreadIds _before_ any
+// function is called after Locking and before execution is given
+// back to JavaScript, e.g. in script->Run(). So until the thread
+// is added to the list Terminate will not be executed. If Terminate
+// is then executed, it is ensured that the current thread is
+// already in the list. If terminate has been called before
+// the Locking, the check for the validiy of fThreadId ensures that
+// nothing is executed.
 //
 // Empty handles:
@@ -938,13 +947,13 @@
 
     Handle<Object> obj = it->second;
-    if (!obj.IsEmpty())
+    if (obj.IsEmpty())
         return;
 
     const Handle<String> onchange = String::New("onchange");
-    if (obj->Has(onchange))
+    if (!obj->Has(onchange))
         return;
 
     const Handle<Value> val = obj->Get(onchange);
-    if (val->IsFunction())
+    if (!val->IsFunction())
         return;
 
