Small changes
Add registerThread() and deregisterThread()

Manage the active thread entries and the token pointer in these two
functions.