Fix threadsafety issue with assignment. Fixes #501. Also, WTF?