Fix some functions that were not thread safe

2 jobs for v8r40p3 in 2 minutes and 2 seconds (queued for 1 second)
latest