Fixed threadsafe issues in producton mode