Fix threading bug.