Problems with concurrent invocation of getOrGenerate.

A sample issue can be found in bfb5508. A possible fix is in f753003. If you like my fix, ebfb07f gets me to 100% coverage.