Added thread locks