Threading fix

It was possible for more than one thread to access the global property
names map at once resulting in contention and possible crashes. Locking
around access to that structure now and moved its declaration inside
getPropertyNames to reduce the temptation to access it elsewhere.