Fixed a bunch of threading issues