Prevent multiple thread writes
Merge branch 'master' into peercoin