Added more locking protections.