Added read/write locking to new functions.