Fix lock assertion errors.