Fix race condition (for real this time)

Need to run subjects_changed in the critical section, otherwise another
thread could come in a compromise our assumptions.