Changed locking to be more memory ordering specific.