Fixed thread-safety issue.

Which also seemed like an unnecessary optimization.

Change-Id: Ifa0f905912f352166fe3c47e1bb68a6a66ec4797
Merge topic 'thread-safety-fix' into master

aadae2e0 Fixed thread-safety issue.