Add more locking around the update mechanism

Hopefully this should stop ConcurrentModificationExceptions.