RMem - TLS functions - changed to be local