merge with threading changes