Fixing issues with thread

- LAST STABLE VERSION.
- thread doesn't end.
- need to fix the thread so it can be paused and resumed.