Improved error message.
Removed thread local memory in two places.  Thanks to Pavel Arnošt.