Fix for concurrency issue

Proposed fix for concurrency issue described in #25.