Made OGT thread-safe and some clean-up