Reduce lock overhead caused by wireddb. Also fixes #1.