Fixed some bugs that caused incorrect threads behaviour