Added global locking.