[MH,RG] Add the functionality for the tosactivity and fix some bugs