Fix misc bugs related to dong/ri data handling