Fix thread safety issue with random helpers