1) Fixed some issues in the threading library