Thread Safety pass

Made a bunch of small tweaks to make some stuff thread safe and thread
ready. Guess what I'm planning to do soon