Added a lock to database helper class, and require DB threads to acquire the lock.