OSX doesn't like thread_local but __thread works
Minor warning fixes