Added locking functions