Updating the threading and adding some debug info