improved locking on database pool.