Fix thread safety for FunctionRegistry