Another locking and segfaulting fix.