added some cross-thread locks