Fixed for threaded build. Fixes #4.