Fix concurrency bugs

- fixes #3