Add some checking to prevent calling GL from another thread. Fix a threading issue where that was happening