Adding synchronization fix to build master

Methods now synchronized to avoid concurrency issues. Contributed by Nathan Grunzweig.