Additional refactoring of the thread class and some testing..