Fixes concurrency issues.

Fixes #87