Fixed crashing issue.

Thread safety is pretty serious business.