Tweak cdata code, make it thread-safe.