Commit 1

Fixed a LOT of bugs, including syncronization of threads,
Now the thread will properly be killed when it has no use.